1class A
2{
3 // constructor
4 A()
5 {
6 cout << "Constructor called";
7 }
8
9 // destructor
10 ~A()
11 {
12 cout << "Destructor called";
13 }
14};
15
16int main()
17{
18 A obj1; // Constructor Called
19 int x = 1
20 if(x)
21 {
22 A obj2; // Constructor Called
23 } // Destructor Called for obj2
24} // Destructor called for obj1
25