Advertisement
TechOPGOHIL

Untitled

Dec 3rd, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3. class kilo; //destination class
  4. class gram
  5. {
  6. float a;
  7. public:
  8. gram()
  9. { a=0; }
  10. gram(float b)
  11. { a=b; }
  12. float getgram() //make function for use value in destination class
  13. {
  14. return(a);
  15. }
  16. void show()
  17. { cout<<"Gram : "<<a<<endl; }
  18. };
  19. class kilo
  20. {
  21. float x;
  22. public:
  23. kilo()
  24. { x=0; }
  25. kilo(float y)
  26. { x=y; }
  27. void show()
  28. { cout<<"Kilo : "<<x<<endl; }
  29. kilo(gram g) //constructor routine in destination class
  30. {
  31. x=g.getgram()/1000;
  32. }
  33. };
  34. void main()
  35. {
  36. clrscr();
  37. kilo k;
  38. gram g(500);
  39. g.show();
  40. k=g;
  41. k.show();
  42. getch();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement