Consider the following class declaration: class Golfer { private: char * fullname; // points to string containing

Question:

Consider the following class declaration:
class Golfer
{
private:
char * fullname; // points to string containing golfer's name
int games; // holds number of golf games played
int * scores; // points to first element of array of golf scores
public:
Golfer();
Golfer(const char * name, int g= 0);
// creates empty dynamic array of g elements if g > 0
Golfer(const Golfer & g);
~Golfer();
};
a. What class methods would be invoked by each of the following statements?
Golfer nancy; // #1
Golfer lulu(“Little Lulu”); // #2
Golfer roy(“Roy Hobbs”, 12); // #3
Golfer * par = new Golfer; // #4
Golfer next = lulu; // #5
Golfer hazzard = “Weed Thwacker”; // #6
*par = nancy; // #7
nancy = “Nancy Putter”; // #8
b. Clearly, the class requires several more methods to make it useful. What additional method does it require to protect against data corruption?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

C++ Primer Plus

ISBN: 9780321776402

6th Edition

Authors: Stephen Prata

Question Posted: