Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
430 views
in Computer by (50.9k points)
closed by

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<<"Planetariurn time over!!!" <<endl;

}; 

(i) What is Function 1 referred as? When will it be executed? 

(ii) Write suitable C++ statement to invoke Function 2.

1 Answer

+1 vote
by (45.3k points)
selected by
 
Best answer

(i) Function 1 referred to as a constructor. It will be executed at the time of object creation.

(ii) C++ statement to invoke Function 2: pianet p; 

p.display(“piuto”, “7.5 Billion km”);

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...