Quick Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Solved Problem Solved Problem#CPP#6970

Problem Statement - 02B-2019S-C1

Observe the following C++ code and answer the questions (i) and (ii).

Note: Assume all necessary files are included.

class Point
{
  int X,Y;
public:
  Point(int I=10, int J=20) //Function 1
  {
     X=J;
     Y=I;
  }
  void Show()      //Function 2
  {
     cout<<"Points are"<<X<<"&"<<Y<<endl;
  }
  ~Point()    //Function 3
  {
     cout<<"Points Erased"<<endl;
  }
};
void main()
{
  Point P(5);
  P.Show();
}

(i) For the class Point, what is Function 3 known as ? When is it executed ?

(ii) What is the output of the above code, on execution ?

Solution