--
#include<iostream.h>
#include<conio.h>
class time
{
int hrs,min,sec;
public:
void accept();
void show();
void sum(time,time);
};
void time::accept()
{
cout<<"\n Enter Hours : ";
cin>>hrs;
cout<<"\n Enter Minutes : ";
cin>>min;
cout<<"\n Enter Second : ";
cin>>sec;
}
void time::show()
{
cout<<"\n Hrs : "<
}
void time::sum(time t1,time t2)
{
sec=t1.sec+t2.sec;
min=sec/60;
sec=sec%60;
min=min+t1.min+t2.min;
hrs=min/60;
min=min%60;
hrs=hrs+t1.hrs+t2.hrs;
}
void main()
{
clrscr();
time t1,t2,t3;
cout<<"\n Enter First Time : ";
t1.accept();
cout<<"\n Enter Second Time : ";
t2.accept();
t3.sum(t1,t2);
t1.show();
cout<<"\n\n--------------------------------";
t2.show();
cout<<"\n\n--------------------------------";
t3.show();
getch();
}
/* Output
Enter First Time :
Enter Hours : 2
Enter Minutes : 55
Enter Second : 60
Enter Second Time :
Enter Hours : 2
Enter Minutes : 65
Enter Second : 60
Hrs : 2 Min : 55 Sec : 60
--------------------------------
Hrs : 2 Min : 65 Sec : 60
--------------------------------
Hrs : 6 Min : 2 Sec : 0
*/