1: #include<iostream>
2: using namespace std;
 3: class time
 4: {
 5:     int h1,m1,s1;
 6:     int h2,m2,s2;
 7:     public:
 8:     void time1()
 9:         {
10:             cout<<"enter the first time: hour,minuate,second\n";
11:             cin>>h1>>m1>>s1;
12:             
13:             
14:             cout<<h1<<":"<<m1<<":"<<s1<<"\n";
15:         }
16:         void time2()
17:         {
18:             cout<<"enter the second time: hour,minute,secod\n";
19:             cin>>h2>>m2>>s2;
20:                 if(s2>=60)
21:             {
22:                 m2=m2+s2/60;
23:                 s2=s2%60;
24:             }
25:             if(m2>=60)
26:             {
27:                 h2=h2+m2/60;
28:                 m2=m2%60;
29:             }
30:             cout<<h2<<":"<<m2<<":"<<s2<<"\n";
31:         }
32:         
33:      friend int add(time x,time y);
34: };
35: int add(time x,time y )
36: {  int h3,m3,s3;
37:     h3=x.h1+y.h2;
38:     m3=x.m1+y.m2;
39:     s3=x.s1+y.s2;  
40:     if(s3>=60)
41:     {
42:         m3=m3+s3/60;
43:         s3=s3%60;
44:     }
45:     if(m3>=60)
46:     {
47:         h3=h3+m3/60;
48:         m3=m3%60;
49:     }
50:     cout<<h3<<":"<<m3<<":"<<s3<<"\n";   
51: }
52: 
53: int main()
54: {
55:     time p,m;
56:     int a;
57:     p.time1();
58:     m.time2();
59:     a=add( p, m);
60:     return 0;
61: }