QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A CBSE12A-2019-A02B-C1 #6970

Question:

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 ?