#include<iostream>
using namespace std;

class Time
{
  private:
    int hour;   // 0 - 23 (24-hour clock format)
    int minute; // 0 - 59
    int second; // 0 - 59
  public:
    Time( int h=0 , int m=0 , int s=0 ){
      setTime( h, m, s );  
    }
    // set functions
    Time & setTime( int h, int m, int s){ // set time
      setHour( h );
      setMinute( m );
      setSecond( s );
      return *this;
    }
    Time& setHour( int h ) 
    {
       hour = ( h >= 0 && h < 24 ) ? h : 0; 
       return *this; // enables cascading
    }
    Time& setMinute( int m ) 
    {
      minute = ( m >= 0 && m < 60 ) ? m : 0; 
      return *this; // enables cascading
    }
    Time &Time::setSecond( int s ) 
    {
       second = ( s >= 0 && s < 60 ) ? s : 0; 
       return *this; // enables cascading
    }
    
    int getHour() const{ // return hour
      return hour;
    }       
    int getMinute() const{ // return minute   
      return minute; 
    }
    int getSecond() const{ // return seco
      return second;
    }
    // print functions (normally declared const)        
    void printTime() const{
      cout<<hour<<" : "<<minute<<" : "<<second<<endl;      
    }
};
main(){
     Time t; 
     // cascaded function calls                      
     t.setHour( 18 ).setMinute( 30 ).setSecond( 22 );
     t.printTime();       // const       const
     t.setTime(20, 20, 20).printTime();
     system("pause");     
}
