हिंदी

Given the following C++ code, answer the following question. In Object-Oriented Programming, what is Function 2 referred to as, and when does it get invoked/called?

Advertisements

प्रश्न

Given the following C++ code, answer the following question.

class TestMeOut
{
public:
~TestMeOut() //Function 1
{cout<<“Leaving the exam hall”<<endl;} TestMeOut() //Function 2
{cout<<“Appearing for exam”<<endl;}
void MyWork() //Function 3
{cout<<“Answering”<<endl;} };

In Object-Oriented Programming, what is Function 2 referred to as, and when does it get invoked/called?

टिप्पणी लिखिए
Advertisements

उत्तर

Function 2 is called the default ‘constructor’.
It is executed automatically when an instance of the class TestMeOut comes into the scope or when objects of the class TestMeOut are created.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 14: Classes and objects - Evaluation - Section - C [पृष्ठ २४७]

APPEARS IN

सामाचीर कलवी Computer Science [English] Class 11 TN Board
अध्याय 14 Classes and objects
Evaluation - Section - C | Q 4. (ii) | पृष्ठ २४७
Advertisements
Share
Notifications



      Forgot password?
Use app×