+ 2

Program for addition of two times values given in hh:mm:ss format using friend function

13th Dec 2017, 11:21 AM
rushikesh ghare
4 Answers
0
Posted it šŸ‘šŸ‘
13th Dec 2017, 11:24 AM
rushikesh ghare
0
where is the friend function used
30th Sep 2019, 4:59 PM
Vijay Kaushal
Vijay Kaushal - avatar
0
Where is friend function
24th Dec 2020, 2:59 AM
Satyaram Chaudhary
Satyaram Chaudhary - avatar
- 1
#include<iostream> using namespace std; class time1 { int hours; int minute; public: void getdata(int h,int m) { hours=h; minute=m; } void putdata(void) { cout<<"Hours:"<<hours<<" and "; cout<<"Minute:"<<minute<<"\n"; } void sum(time1,time1); }; void time1::sum(time1 t1,time1 t2) { minute=t1.minute+t2.minute; hours=minute/60; minute=minute%60; hours=hours+t1.hours+t2.hours; } int main() { time1 t1,t2,t3; t1.getdata(2,30); t2.getdata(1,45); t3.sum(t1,t2); cout<<"first entered time=";t1.putdata(); cout<<"second entered time=";t2.putdata(); cout<<"Adddition of the both time=";t3.putdata(); return 0; }
13th Dec 2017, 11:21 AM
rushikesh ghare