Question: Checkpoint 15.4 (page 917). Trace the program and answer following questions. #include using namespace std; class Sky { public: Sky() { cout < < Entering

Checkpoint 15.4 (page 917). Trace the program and answer following questions.

#include using namespace std;

class Sky

{

public: Sky() { cout << "Entering the sky. "; } ~Sky() { cout << "Leaving the sky. "; }

}; class Ground : public Sky

{

public: Ground() { cout << "Entering the Ground. "; } ~Ground() { cout << "Leaving the Ground. "; }

};

int main()

{ Ground object; return 0;

}

a. What is the output of the program?

b. Which is base class? Which is derived class?

c. Are constructors executed? Which constructor is called, and in what order are they executed?

d. Are destructors executed? Which destructor is called, and in what order are they executed?

Checkpoint 15.8 (page 918). Trace the program and answer following questions.

#include using namespace std;

class Sky

{

public: Sky() { cout << "Entering the sky. "; } Sky(string color) { cout << "The sky is " << color << endl; } ~Sky() { cout << "Leaving the sky. "; }

}; class Ground : public Sky

{

public: Ground() { cout << "Entering the Ground. "; } Ground(string c1, string c2) : Sky(c1) { cout << "The ground is " << c2 << endl; } ~Ground() { cout << "Leaving the Ground. "; }

};

int main()

{ Ground object; return 0;

}

a. What is the output of this program?

b. Which is base class? Which is derived class?

c. Are constructors executed? Which constructor is called, and in what order are they executed?

d. Are destructors executed? Which destructor is called, and in what order are they executed?

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!