#include <iostream>
using namespace std;
class Watch{
int second;
public:
Watch();
void reset();
void run();
void disp();
void tick();
void wait();
};
Watch::Watch()
{
cout << "call constructor" << endl;
cout << "--this=" << this << "--" << endl;
second=0;
}
void Watch::reset()
{
second=0;
}
void Watch::run()
{
for(int i=0; i<100; i++){
tick();
disp();
}
}
void Watch::tick()
{
wait();
second++;
}
#include <ctime>
void Watch::wait()
{
time_t t=time(NULL);
while(time(NULL)==t);
}
void Watch::disp()
{
cout << '\r' << '\a' << second << flush;
}
int main()
{
Watch w;
w.run();
}