Answer to Question #251780 in C++ for Gulli

Question #251780
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-17T09:29:19-0400

i) Seminar s; // The statement will execute Function 1 of the class Seminar

Seminar s1(10);// This statement will execute Function 2 of the class Seminar

ii) Function 4 is Destructor. A destructor is called when an object of a class goes out of scope.

iii) Data encapsulation and data hiding.



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