Miscellany
public text v1 · immutable#include <iostream>
#include <time.h>
using std::cout;
using std::endl;
class Time {
public:
Time(int value) {setTime();}
void printTime();
void setTime() {value=time(NULL);}
private:
int value;
}
Time::Time(int value) {setTime();}
void Time::setTime()
{
value=time(NULL);
}
void Time::printTime()
{
cout << "Current time is: "<< ctime(&value) << endl;
}
int main()
{
Time t;
t.printTime();
return 0;
}