AbdulFathaah

time instances C++

Dec 10th, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. /*read and display two time instances*/
  2. #include<iostream.h>
  3. #include<conio.h>
  4.  
  5. class time
  6. {
  7. private : int hour,min,sec;
  8. public : void read();
  9. void display();
  10. };
  11. void time :: read()
  12. {
  13. cout<<"Enter hour: ";
  14. cin>>hour;
  15. cout<<"Enter minute: ";
  16. cin>>min;
  17. cout<<"Enter second: ";
  18. cin>>sec;
  19. }
  20. void time :: display()
  21. {
  22. cout<<hour<<":"<<min<<":"<<sec;
  23. }
  24. int main()
  25. {
  26. time t1,t2;
  27. clrscr();
  28. t1.read();
  29. t1.display()
  30. cout<<"\n";
  31. t2.read();
  32. t2.display();
  33. getch();
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment