Ok I posted something earlier about this but was asking for too much at once so I am going to try to break this up now as I find myself needing help.
Being a beginner to C++, I am right now stuck on declaring the member functions in the header file.
Right now I need to create an assign member function that accepts a string object parameter. This checks for the assignment to itself and then assigns a new value to this String from the parameter String, making a deep copy of the character data.
So in my header file this would be declared as something like:
im going to worry about defining the member fuctions after i finish declaring them in the header, so im just looking to get this part done right now.Code:#ifndef _TSTRING_H #define _TSTRING_H class TString { // Prefix with 'T' for uniqueness public: TString(const char *pText = 0); // default ctor TString(const TString &); ~TString(); int length() { return mLength; } const char *asChar() const; void assign(string obString); //<---- member function in question private: int mLength; // length of char data (not including null byte) char *mpText; // pointer to dynamic char data in heap }; #endif // _TSTRING_H



LinkBack URL
About LinkBacks


