Answer to Question #251728 in C++ for Gulli

Question #251728
Q2: 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-10-15T05:25:39-0400

1.

Seminar default_ctor; // func 1
Seminar other_ctor(10); // func 3

2.It's a destructor. It's being invoked when the object is going to be destroyed, i.e. object is out of scope where it's been created.

3.They are constructors (default and with parameter)


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
APPROVED BY CLIENTS