[try Beta version]
Not logged in

 
Constructor -initialize this class into an empty class?

Feb 18, 2011 at 2:21am
Lets say I have class TheClass. In the constructor, how do I initialize this TheClass to be an empty TheClass?
Feb 18, 2011 at 2:29am
Define "empty".
Feb 18, 2011 at 2:33am
Well i'm buiilding a custom string class (Called MyString) for a school course, and in the constructor we are told to "initialize this MyString to an empty MyString" But i'm not sure what that meaneth.
Feb 18, 2011 at 6:55am
You can using a char array "myString" to store string.
if myString[0] is '\0', this is a empty string.
But at beginning you should give a definite number "n" to initialize "myString". And please be aware of "myString" can only contain n-1 character.
Topic archived. No new replies allowed.