Next change the information in both objects by calling the


1. What must happen to allow private members of a class to be inherited by a derived class?

2. Describe the order of function execution for base and derived constructor functions and for destructor functions.

3. If the overloaded constructor is used when constructing a child class object, but the child's constructor doesn't explicitly call the parent's overloaded constructor, which, if any parent constructor is called?

4. Write a program that sets up a base class Sailor containing protected data for name, rank, and serial number. There should be two constructor functions: one is empty and the other has the three data values as inputs. The other member functions should include a GetInfo function (asks the user for Sailor information) as well as a WriteInfo (writes all the Sailor data to the screen).

Next derive a new class from Sailor. The Sailor_At_Sea class has the name of the ship to which the Sailor has been assigned, as well as the name of the ship's home port. The Sailor_At_Sea class also has two constructor functions: one that does nothing and the other that receives all the possible Sailor data. This derived class constructor passes the sailor data to the base class constructor. There are also WriteInfoand GetInfo functions that call the associated Sailor functions before handling the derived class specific data.

The main function has several steps.

1. Initially it should declare one Sailor and one Sailor_At_Seaobjects. Simply make up all the data and pass it into the objects when they are created.

2. Call the WriteInfo functions and verify that the objects were created with the data you passed into them.

3. Next, change the information in both objects by calling the GetInfo functions, and then call the WriteInfofunctionto verify that the object data has been changed.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Next change the information in both objects by calling the
Reference No:- TGS01384281

Now Priced at $50 (50% Discount)

Recommended (99%)

Rated (4.3/5)