Well, a good way to handle this would be like so:
There. Now you don't even need a copy constructor, because the default copy constructor will suffice. You also don't have to worry about writing an assignment operator or a destructor, which you would have if your class used a char* with dynamically allocated memory.Code:class A { public: A::A(); // constructor // some other functions private: std::string name; // the name of the object is stored in a character array };
Isn't the standard template library great?




Reply With Quote