Create a class Clock that contains
integer data membersas hours, minutes and seconds. Write a C++ program to
perform following member functions:
voidsetclock(int, int, int ) to set the
initial time of clock object.
voidshowclock() to display the time in
hh:min:sec format.
Write a function tick( ) which by
default increment the value of second by 1 or according to user specified
second.The clock uses 24 hours format.
#include<iostream.h>
#include<conio.h>
#include<dos.h>
class
time1
{
             
int h,m,s,ms;
             
public:
             
void setclock()
             
{
                        h=m=s=0;
             
}
             
void showclock()
             
{
                        if(s>59)
                        {
                                    s=0;
                                    m++;
                        }
                        else if(m>59)
                        {
                                    m=0;
                                    h++;
                        }
                        cout<<endl<<h<<":"<<m<<":"<<s;
             
}
             
void tick()
             
{
                        s++;
             
}
};
void
main()
{
            clrscr();
            time1 t1;
            if(1)
            {
                        t1.setclock();
                        while(!kbhit())
                        {
                                    t1.showclock();
                                    delay(500);
                                    t1.tick();
                        }
            }
            getch();
}
 




