Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

answer using c++ Module 7: Classes Continued Questions Question 1 In what order

ID: 3868687 • Letter: A

Question


answer using c++

Module 7: Classes Continued Questions Question 1 In what order are class constructors and class destructors called when a derived class object is created and deleted? Question 2 Can you assign the address of an object of a derived class to a pointer to the base class? Can you assign the address of an object of a base class to a pointer to the derived class? Question 3 Suppose Corporation is a base class and PublicCorporation is a derived class. Also suppose that each class defines a head0 member function, that ph is a pointer to the Corporation type, and that ph is assigned the address of a PublicCorporation object. How is ph->head0 interpreted if the base class defines head0 as a a. Regular nonvirtual method b. Virtual method

Explanation / Answer

1)Answer:

the order in which constructors are called when an object of a derived class is created.

- The constructors of any virtual base classes are called first in the order of inheritance.

- Non-virtual base class constructors are called next.

- The derived class constructor is called last.

- The derived class constructor has only access to its own class members

The order is given below

example:

Output of example:

Construct B

Construct D

Destruct D

Destruct B