Saved Bookmarks
| 1. |
Given the following C++ code, answer the questions (i) & (ii).class TestMeOut{public:~TestMeOut() //Function 1 {cout << “Leaving the examination hall” << endl;}TestMeOut() //Function 2{cout<<“Appearing for examination”<<endl;}void MyWork() //Function 3{cout<<“Attempting Questions//<<endl;}};1. In Object Oriented Programming, what is Function 1 referred as and when does it get invoked / called?2. In Object Oriented Programming, what is Function 2 referred as and when does it get invoked / called? |
|
Answer» 1. Function 1 is the ‘destructor’. It is executed automatically when an object of the class TestMeOut goes out of scope. 2. Function 2 is called default ‘constructor’. It is executed automatically when instance of the class TestMeOut comes into scope or when objects of the class TestMeOut are created. |
|