#include<iostream.h>
#include<conio.h>
#include<string.h>
class time
{
int min,sec;
public:
int hr;
void settime(int h,int m,int sec);
void show();
};
class clock:public time
{
char str[3];
public:
void setampm();
};
void time::settime(int h,int m,int s)
{
hr=h;min=m;sec=s;
}
void time::show()
{
cout<<hr<<":"<<min<<":"<<sec;
}
void clock::setampm()
{
if(hr>=12)
strcpy(str,"PM");
else
strcpy(str,"AM");
cout<<str;
}
void main()
{
clrscr();
clock c;
c.settime(13,50,45);
c.show();
c.setampm();
getch();
}
Comments
Post a Comment