#include <iostream>
using namespace std;

class ClockType
{
	friend ostream& operator<< (ostream&, const ClockType&);
	
	public:
		ClockType ();
		
		ClockType (int, int, int);
		
		ClockType& operator++ ();	// pre-increment
		ClockType operator++ (int); // post-increment
		ClockType& operator-- ();

	private:
		int hour, minute, second;
};

ostream& operator<< (ostream& os, const ClockType& ct)
{
	if (ct.hour < 10)
		os << "0";
	os << ct.hour << ":";
	
	if (ct.minute < 10)
		os << "0";
	os << ct.minute << ":";
	
	if (ct.second < 10)
		os << "0";
	os << ct.second;
	
	return os;
}
ClockType::ClockType ()
{
	hour = 0;
	minute = 0;
	second = 0;
}

ClockType::ClockType (int hour, int minute, int second)
{
	this -> hour = hour;
	this -> second = second;
	this -> minute = minute;
}

ClockType& ClockType::operator++ ()
{
	second++;
	
	if (second == 60)
	{
		second = 0;
		minute++;
		
		if (minute == 60)
		{
			minute = 0;
			hour++;
			
			if (hour = 24)
				hour = 0;
		}
	}
	
	return *this;
}

ClockType ClockType::operator++ (int n) // post-increment
{
	ClockType temp = *this;
	
	second++;
	
	if (second == 60)
	{
		second = 0;
		minute++;
		
		if (minute == 60)
		{
			minute = 0;
			hour++;
			
			if (hour = 24)
				hour = 0;
		}
	}
	
	return temp;
}	   
	

ClockType& ClockType::operator-- ()
{
	second--;
	
	if (second == -1)
	{
		second = 59;
		minute--;
		
		if (minute == -1)
		{
			minute = 59;
			hour--;
			
			if (hour == -1)
				hour = 23;
		}
	}
		
	
	return *this;
}	


int main ()
{
	ClockType ct1 (8, 9, 34);
	++ct1;			// work on pre-incerement
	cout << ct1 << endl;
	
	ClockType ct2 (23, 59, 59);
	++ct2;
	cout << ct2 << endl;
	
	--ct2;
	cout << ct2 << endl;
	
	ct1++;
	cout << ct1 << endl;	
}

