C++ Output: Constructor and Destructor Order for Dog Inheriting Animal

Company: Deloitte USI_5sep

Difficulty: medium

Problem Statement

Question 1

What is the output of the following code? ```cpp #include using namespace std; class Animal { public: Animal() { cout << "A "; } ~Animal() { cout << "~A "; } }; class Dog : public Animal { public: Dog() { cout << "D "; } ~Dog() { cout << "~D "; } }; int main() { Dog d; } ```