Question: C++ Step1 - Define two classes, Whole and part. Use a strong has a relationship with the two classes. Constructor Functions Define a default constructor

C++

Step1 - Define two classes, Whole and part. Use a strong "has a" relationship with the two classes.

Constructor Functions

Define a default constructor for the Part class.

Default just prints out "In default part constructor"

Define a default and a parm constructor for the Whole class.

In Whole Default constructor assigns wholeName = "None"; and prints out "In whole default Constructor"

In Whole Parm constructor - Passes in name to WholeName and

Then It prints out value of wholeName variable and "In Whole parm constructor"

Destructor Functions

Define a destructor function for the part class.

Define a string variable called wholeName in the whole class.

Define a getName function for whole class.

Two test.

Step 2 - Declare a Whole W1, with default constructor

Have the Whole constructor print "called default constructor", and contents of wholeName variable

Have the Whole Destructor print "called destructor", and contents of wholeName variable

Declare a Whole W2, with a parm constructor - Have it pass in "w2"

Have the Whole constructor print "called parm constructor", and contents of wholeName variable.

Have the Whole Destructor print "called destructor", and the contents of wholeName variable.

Step 3 - use the dot

Use the dot notation to print out the contents of W1 wholeName variable

Use the dot notation to print the contents of W2 wholeName variable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!