November 2001
Beginner
1128 pages
29h 12m
English
| 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 using a string object instead. What methods no longer need an explicit definition? |
| 2: | Name at least two advantages string objects have over C-style strings in terms of ease-of-use. |
| 3: | Write a function that takes a reference to a string as an argument and which converts the string to all uppercase. |
| 4: | Which of the following are not examples ... |
Read now
Unlock full access