#include<iostream.h>
#include<time.h>
#include<conio.h>
class secondwatch
{
public:
secondwatch()
{
itsbegin=itsend=0;
}
void start()
{
cout<<"请按任意键确定计时开始"<<endl;
_getch();
itsbegin=double(clock())/CLOCKS_PER_SEC;
cout<<"计时开始。。。。"<<endl;
}
void end()
{
cout<<"请按任意键确定计时结束"<<endl;
_getch();
itsend=double(clock())/CLOCKS_PER_SEC;
cout<<"计时结束!!"<<endl;
}
void show()
{
cout<<"共耗时"<<(itsend-itsbegin)<<"秒";
cout<<endl;
}
private:
double itsbegin,itsend;
};
int main()
{
secondwatch s;
s.start();
s.end();
s.show();
return 0;
}