+2 votes
in Class 10 by kratos

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 ****?

II. Write suitable C++ statement to invoke Function 2.

1 Answer

+3 votes
by kratos
 
Best answer

I. Constructor

It will be **** at the time of object creation.

II. planet p;

p.display(“Pluto”,”7.5 Billion Km”);

...