Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

To illustrate exactly when an object is constructed and destructed when returned from a function, create a C++ class called who. Have who's constructor take...

To illustrate exactly when an object is constructed and destructed when returned from a function, create a C++ class called who. Have who's constructor take one character argument that will be used to identify an object.Have the constructor display a message similar to this when constructing an object:
Constructing who #X
where x is the identifying character associated with each object when an object is destroyed, have a message similar to this displayed:
Destroying who #x
where, again, x is the identifying character. Finally, create a function called make_who() that returns a who object. Give each object a unique name.Note the output displayed by the program.

Answers


Davis
#include
using namespace std;
class who {
char name;
public:
who(char c) {
nam= c;
cout << "Constructing who #";
cout << name << "\n";
}
~who() { cout << "Destructing who #" << name << "\n";} };
who makewho()
{
wh'B ');
return temp;
}
int main()
{
who ob('A');
makewho();
return o;
}
Githiari answered the question on May 12, 2018 at 17:56

Answer Attachments

Exams With Marking Schemes

Related Questions