Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*read and display two time instances*/
- #include<iostream.h>
- #include<conio.h>
- class time
- {
- private : int hour,min,sec;
- public : void read();
- void display();
- };
- void time :: read()
- {
- cout<<"Enter hour: ";
- cin>>hour;
- cout<<"Enter minute: ";
- cin>>min;
- cout<<"Enter second: ";
- cin>>sec;
- }
- void time :: display()
- {
- cout<<hour<<":"<<min<<":"<<sec;
- }
- int main()
- {
- time t1,t2;
- clrscr();
- t1.read();
- t1.display()
- cout<<"\n";
- t2.read();
- t2.display();
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment