Answer to Question #203733 in C++ for python

Question #203733

Answer the questions (i) and (iii) after going through the following class:

class Seminar

{

int time;

public:

Seminar() //Function 1

{

time = 30;

cout << "Seminar starts now" << endl;

}

void lecture() //Function 2

{

cout << "Lectures in the seminar on" << endl;

}

Seminar(int duration) //Function 3

{

time = duration;

cout << "Seminar starts now" << endl;

}

~Seminar() //Function 4

{

cout << "Thanks" << endl;

}

};

i. Write statements in C++ that would execute Function 1 and Function 3 of class Seminar.

ii. In Object Oriented Programming, what is Function 4 referred as and when does it get

invoked/called?

iii. In Object Oriented Programming, which concept is illustrated by Function 1 and Function 3

together?


1
Expert's answer
2021-06-06T17:08:06-0400

(i)

Seminar s1,s2(2);

(ii)

Function 4 is called a destructor.

A destructor function is called automatically when the object goes out of scope: 

(1) the function ends 

(2) the program ends 

(3) a block containing local variables ends 

(4) a delete operator is called  


(iii)

Function 1 and Function 3 illustrates the concept of constructor overloading. We can have more than one constructor in a class with same name, as long as each has a different list of arguments. This concept is known as Constructor Overloading and is quite similar to function overloading.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog