The following procedure shows how to create a CTime object and initialize it with the current time.
To get the current time
CTime theTime;
Note Uninitialized CTime objects are not initialized to a valid time.
theTime = CTime::GetCurrentTime();
Since GetCurrentTime is a static member function from the CTime class, you must qualify its name with the name of the class and the scope resolution operator (::), CTime::GetCurrentTime()
.
Of course, the two steps outlined previously could be combined into a single program statement as follows:
CTime theTime = CTime::GetCurrentTime();