Get premium membership and access questions with answers, video lessons as well as revision papers.

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


Next: Illustrate the change of a C++ stack so it dynamically allocates memory for the stack.Have the size of the stack specified by a parameter to...
Previous: Create a class called box whose constructor function is passed three double values, each of which represents the length of one side of a box.Have...

View More Computer Science Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions