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.

Create a class C++ class called t_and_d that is passed the current system time and date as a parameter to its constructor when it is...

Create a class C++ class called t_and_d that is passed the current system time and date as a parameter to its constructor when it is created.Have the class include a member function that displays this time and date on the screen.

Answers


Davis
#include
#include
using namespace std;
class t_and_d {
time_t systime;
public:
t_and_d(time_t t); //constructor
void show();
};
t_and_d::t_and_d(time_t t)
{
systime = t;
}
void t_and_d::show()
{
cout << ctime(&systime);
}
int main()
{
time_t x;
x = time(NULL);
t_and_d on(x);
on.show();
return 0;
}

Githiari answered the question on May 5, 2018 at 17:50

Answer Attachments

Exams With Marking Schemes

Related Questions