Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<conio.h>
- #include<iostream.h>
- class time
- {
- int hrs,mins;
- public :
- time(int,int);
- operator int();
- };
- void time::time(int a,int b)
- {
- hrs=a;
- mins=b;
- }
- time::operator int()
- {
- return(hrs*60+mins);
- }
- int main()
- {
- int h,m,tot_min1;
- clrscr();
- cout<<"Enter the value of Hrs : ";
- cin>>h;
- cout<<"Enter the value of Mins : ";
- cin>>m;
- time t1(h,m);
- tot_min1=t1;
- cout<<"total Minutes : "<<tot_min1<<endl;
- cout<<"Using Second Method"<<endl;
- int tot_min2=t1.operator int();
- cout<<"Total Minutes : "<<tot_min2<<endl;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement