SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Inheritance
Exercise:
Self-test Exercises
Question:8 | ISBN:9780321531346 | Edition: 7

Question

Suppose Child is a class derived from the class Parent, and the class

Grandchild is a class derived from the class Child. This question is concerned with the constructors and destructors for the three classes Parent, Child, and Grandchild. When a constructor for the class Grandchild is invoked, what constructors are invoked and in what order? When the

destructor for the class Grandchild is invoked, what destructors are

invoked and in what order?

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

The constructors are called in the following order: first Parent, then

Child, and finally Grandchild. The destructors are called in the reverse

order: first Grandchild, then Child, and finally Parent.

0 0

Discussions

Post the discussion to improve the above solution.