Our assignment calls for us to create a user defined string class, without using anything from the directories string.h, string, or cstring.
however in the implementation file we're given, there are two different forms of the constructor.
and
The variables are as follows.
I have a general idea about the string& constructor, though I'm not sure how to apply the c-type data.
but I know that's not right, namely the Mem part.
the const char [] constructor is really where I have no clue, since I'm not sure how to check the length of the data being inserted into the array, namely, how to set Length.
Also, How does the program differentiate between the two constructors? what If I were to compare two different 'strings' and wanted to use the c-type array?
Help is greatly appreciated.
however in the implementation file we're given, there are two different forms of the constructor.
Code:
String(const string&);
Code:
String(const char[ ] );
Code:
unsigned Length; unsigned Capacity; char * Mem;
Code:
String::String(const string& RHS )
{
Length = RHS.Length;
Capacity = RHS.Capacity;
Mem = RHS;
}
the const char [] constructor is really where I have no clue, since I'm not sure how to check the length of the data being inserted into the array, namely, how to set Length.
Also, How does the program differentiate between the two constructors? what If I were to compare two different 'strings' and wanted to use the c-type array?
Help is greatly appreciated.
Comment