InterviewSolution
Saved Bookmarks
| 1. |
Answer the questions(i) and (ii) after going through the following class:class planet{char name[20];char distance[20];public:planet() //Function 1{strcpy(name, "Venus");strcpy(distance,"38 million km");}void display(char na[],char d[]) //Function 2{cout<<na<<"has "<<d<<" distance from Earth"<<endl;}planet(char na[], char d[]) //Function 3{strcpy(name,na);strcpy(distance,d);}~planet() //Function 4{cout<<"Planetarium time over!!!"<<endl;}};I. What is Function 1 referred as? When will it be executed?II. Write suitable C++ statement to invoke Function 2. |
|
Answer» I. Constructor It will be executed at the time of object creation. II. planet p; p.display(“Pluto”,”7.5 Billion Km”); |
|