Question: Consider the following class declaration: class Golfer { private: char * fullname; // points to string containing golfer's name int games; // holds number of
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?
Step by Step Solution
3.12 Rating (178 Votes )
There are 3 Steps involved in it
a The class method that would be invoked by each statement is as follows 1 The default constructor 2 ... View full answer
Get step-by-step solutions from verified subject matter experts
