Advertisement
TechOPGOHIL

Untitled

Dec 3rd, 2023
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include<conio.h>
  2. #include<iostream.h>
  3. class time
  4. {
  5. int hrs,mins;
  6. public :
  7. time(int,int);
  8. operator int();
  9. };
  10. void time::time(int a,int b)
  11. {
  12. hrs=a;
  13. mins=b;
  14. }
  15. time::operator int()
  16. {
  17. return(hrs*60+mins);
  18. }
  19. int main()
  20. {
  21. int h,m,tot_min1;
  22. clrscr();
  23. cout<<"Enter the value of Hrs : ";
  24. cin>>h;
  25. cout<<"Enter the value of Mins : ";
  26. cin>>m;
  27. time t1(h,m);
  28. tot_min1=t1;
  29. cout<<"total Minutes : "<<tot_min1<<endl;
  30. cout<<"Using Second Method"<<endl;
  31. int tot_min2=t1.operator int();
  32. cout<<"Total Minutes : "<<tot_min2<<endl;
  33. getch();
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement