// Implementation of Stopwatch class #include "stopwatch.h" #include <iostream> using namespace std; Stopwatch::~Stopwatch() { if ( message ) { cout << title << '\n'; } if ( delay ) { //delay output on the screen char dummy; cin >>dummy; } //get elapsed time clock_t total = clock()-start; cout << "total of ticks for this activity: " << total << endl; cout << "in microseconds: " << double(total/(CLK_TCK)) << " a tick is " << CLK_TCK << endl; } // set a title to this measurement string Stopwatch::set_title(string s) { title = string(s); message = true; return title; } string Stopwatch::set_title(char* s) { title = string(s); message = true; return title; } string Stopwatch::get_title() { return title; }
Hosted by www.Geocities.ws

1