Question: Consider the following class declaration: class RQ1 { private: char * st; // points to C-style string public: RQ1() { st = new char [1];
Consider the following class declaration:
class RQ1
{
private:
char * st; // points to C-style string
public:
RQ1() { st = new char [1]; strcpy(st,""); }
RQ1(const char * s)
{st = new char [strlen(s) + 1]; strcpy(st, s); }
RQ1(const RQ1 & rq)
{st = new char [strlen(rq.st) + 1]; strcpy(st, rq.st); }
~RQ1() {delete [] st};
RQ & operator=(const RQ & rq);
// more stuff
};
Convert this to a declaration that uses a string object instead. What methods no longer need explicit definitions?
Step by Step Solution
3.46 Rating (149 Votes )
There are 3 Steps involved in it
class RQ1 private string st points to Cstyle string public RQ1 st RQ... View full answer
Get step-by-step solutions from verified subject matter experts
