May 2012
Intermediate to advanced
679 pages
16h 56m
English
We have studied keyword static earlier in this chapter. The class Timer gives us a nice opportunity to study static as well as non-static methods of a given class. In many programs, we would like to measure the time taken by the critical code. Well someone will suggest a stopwatch. Can we implement the stopwatch in our program? By all means! What is a stopwatch anyway? It measures elapsed time between two events start and stop. C++ provides us with a method time() in header file “time.h”. This method returns the time from a predefined reference to current time as a long integer. It can be effectively used to measure the elapsed time.
Problem: Write a program to illustrate static methods start, ...
Read now
Unlock full access