Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  time
Language: C/C++
Code:
#include<iostream.h>
#include<conio.h>
class time
{
int hr;
int min;
int sec;
public:

 time(int h,int m,int s )
 {
 hr=h;min=m;sec=s;
 }
 void operator ++();
 void show_time();

};
void time::operator ++()
{
      sec= sec+1;
      if(sec>=60)
      {
      sec=sec-60;
      min=min+1;
      }
      if(min>=60)
      {
      min=min-60;
      hr=hr+1;
      }
}
void time:: show_time()
{
cout<<"nTime is = "<<hr<<":"<<min<<":"<<sec;
}
void main()
{
 clrscr();
 time t(12,59,59);
 cout<<"nBefore Incrementing Time:";
 t.show_time();
 ++t;
 cout<<"nAfter Incrementing Time:";
 t.show_time();
 getch();
}

          
Comments: