Simple Example of VC ++
// Clock_app.cpp
// # Include <iostream>
# Include "clock. H"
// Main Function
Int main ()
{
Clock myclock;// Define the object myclock, call the constructor implicitly, and use the initial value as the real parameter.
Cout <"First time set and output:" <Endl;
Myclock. settime ();// Set the time to the default value (because the default value is set during function declaration)
Myclock. Showtime ();// Display time
Cout <"second time set and output:" <Endl;
Myclock. settime (8, 30, 30 );// Set the time To 8:30:30.
Myclock. Showtime ();// Display time
}
// Clock. h
# Include <iostream>
Using namespace STD;
Class clock // Clock Declaration
{
Public: // External interface, Public member function
Void settime (INT newh = 0, int newm = 0, int news = 0 );
Void Showtime ();
PRIVATE: // Private Data Member
Int hour, minute, second;
};
// Clock. cpp
# Include "clock. H"
// Implementation of clock-class member functions
Void clock: settime (INT newh, int newm, int News)
{
Hour = newh;
Minute = newm;
Second = News;
}
Void clock: Showtime ()
{
Cout }