Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<conio.h>
- #include<iostream.h>
- class map
- {
- int kilo;
- int gram;
- public:
- map()
- {
- kilo=0;
- gram=0;
- }
- map(int f)
- {
- kilo=f/1000;
- gram=f%1000;
- }
- void show()
- {
- cout<<endl<<" Kilo is :- "<<kilo;
- cout<<endl<<" Gram is :- "<<gram;
- }
- };
- int main()
- {
- int f;
- clrscr();
- cout<<endl<<" Enter weight in grams : ";
- cin>>f;
- map t1;
- t1=(int)f; /* first method using assignment operator */
- /* above statement invoke parameterized constructor */
- t1.show();
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement