![]() |
|
#1
|
|||
|
|||
Not sure I understand this assignment....Here's the (abbreviated) code for a simple string class - I've deleted most of the member functions for this post. An assignment asks
Quote:
What I don't get is that the constructor (as copied from the book) initializes with a length of 0, so there aren't any character positions to store into, right? If the constructor either initialized with a length greater than 0 or accepted an argument for the length, then the assignment would make sense to me. Am I being dense, or is this assignment bogus? Header: CPP / C++ / C Code:
CPP / C++ / C Code:
|
|
#2
|
|||
|
|||
Re: Not sure I understand this assignment....Quote:
|
|
#3
|
|||
|
|||
Re: Not sure I understand this assignment....Quote:
|
|
#4
|
|||
|
|||
Re: Not sure I understand this assignment....Quote:
|
|
#5
|
|||
|
|||
Re: Not sure I understand this assignment....Quote:
I tend to get into trouble when I read more into the assignment than is explicitly stated, so am tending to be more conservative and sticking to whatever is explicitly stated. In every other assignment so far, when they want you to modify the constructor to accept an argument, they tell you. Anyway, thanks for your response(s). |
|
#6
|
|||
|
|||
Re: Not sure I understand this assignment....Quote:
|
|
#7
|
||||
|
||||
Re: Not sure I understand this assignment....Quote:
Look at the variables associated with each object... the length is only an integer storing the length of the string. The attribute holding the actual data is the character array 'contents'. This array is initialized to hold 255 characters as is stated in the enum. So, just because the length variable is set to 0 doesn't mean that the allotted space for that string is 0... it is in fact 255. Hope that helped. __________________
If practice makes perfect and nobody's perfect... why practice? Homepage: http://www.treywhite.com Blog: http://www.treywhite.com/blog.php Web Design Company: http://www.ewebproductions.com |
|
#8
|
|||
|
|||
Re: Not sure I understand this assignment....Ack!
I obviously have to much on mind to give any good help. So I think I will take a break for a while. |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Circular Linked Queue Copy Constructor and Assignment Operator Not Working? | wc3promet | C++ Forum | 1 | 06-Oct-2008 04:00 |
| private copy and assignment operator | alcoholic | C++ Forum | 4 | 14-Jan-2006 02:35 |
| assignment ..... | talal2929 | C++ Forum | 5 | 16-Dec-2005 18:36 |
| overload assignment operator with non-member function (assign class to int/dbl/str) | ubergeek | C++ Forum | 6 | 06-Apr-2005 03:04 |
| help with c++ object assignment | Mjkramer21 | C++ Forum | 31 | 14-Apr-2004 19:51 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The