Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- class kilo; //destination class
- class gram
- {
- float a;
- public:
- gram()
- { a=0; }
- gram(float b)
- { a=b; }
- float getgram() //make function for use value in destination class
- {
- return(a);
- }
- void show()
- { cout<<"Gram : "<<a<<endl; }
- };
- class kilo
- {
- float x;
- public:
- kilo()
- { x=0; }
- kilo(float y)
- { x=y; }
- void show()
- { cout<<"Kilo : "<<x<<endl; }
- kilo(gram g) //constructor routine in destination class
- {
- x=g.getgram()/1000;
- }
- };
- void main()
- {
- clrscr();
- kilo k;
- gram g(500);
- g.show();
- k=g;
- k.show();
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement