Topic Wise Solved Problems Question – Computer Sir Ki Class

Login


Lost your password?

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


Shop
siteicon
CPP: Topicwise Exam Question: class-function-types siteicon
02B-2015 2

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

class Passenger
{
  long PNR;
  char Name [20] ;
public:
  Passenger()                 //Function 1
  { cout<<"Ready"<<endl; }
  
  void Book(long P,char N[])  //Function 2
  { PNR = P; strcpy(Name, N); }
  
  void Print()                //Function 3
  { cout«PNR << Name <<endl; }
  
  ~Passenger()                //Function 4
  { cout<<"Booking cancelled!"<<endl; }
};

(i) Fill in the blank statements in Line 1 and Line 2 to execute Function 2 and Function 3 respectively in the following code:

void main()
{
  Passenger P;
  ___________ //Line 1
  ___________ //Line 2
}//Ends here

(ii) Which function will be executed at } //Ends here? What is this function referred as ?

CBSE12A-2015