are necessary c statements s points each Ninclude ciomanipa

are necessary c statements (s points each) Ninclude ciomanipa. using namespace std; int month int day. int year, Date (int 7. int 4. int 2011 constructor wth detauts Date (const copy constructor void showdate0 Date: Date(nt mm. int dd, int yyyy) year Date: Date(const Date& olddate) menn. month. year olddate year, void Date: showdate0 set (2) month set (2)

Solution

The answers to the above blanks are as follows:

a). private (or protected)

Explanation: An access modifier is required at this position to tell the compiler the scope of access of these members (month, day, year) we want to have in the program. We can use private or protected access modifier here. Data members of a class should always be kept as private to the class so that they remain isolated from outside world. Private members of a class cannot be accessed outside the class by any other classes, objects or functions. Only public members (such as member functions) should be allowed to access the private data so that security of the objects of the classes is not compromised. Protected modifier may also be used but since we do not intend to inherit this Date class anywhere else in the program, we would not need to access the members in sub classes. Hence, private is a more appropriate choice.

b). Date &olddate

Explanation: With the help of a copy constructor, we may copy the values of some other object of the same class into our current object. In order to achieve this feature, we need to pass a reference of the other object (&olddate in this case) to the copy constructor. If we do not expliicitly define a copy constructor for our class, and a need arises for this at some time while compiling the program, the compiler provides a copy constructor itself to the class.

 are necessary c statements (s points each) Ninclude ciomanipa. using namespace std; int month int day. int year, Date (int 7. int 4. int 2011 constructor wth d

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site