netx_iit

Class to class conversion

Dec 28th, 2020 (edited)
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. class dollar
  4. {
  5.     int d;
  6.     public:
  7.         int get_data()
  8.         {
  9.             cout<<"\n Enter dollar";
  10.             cin>>d;
  11.             return d;
  12.         }
  13. };
  14. class rupee
  15. {
  16.     int rs;
  17.     public:
  18.         rupee()
  19.         {
  20.             rs=0;
  21.         }
  22.         rupee(dollar d)
  23.         {
  24.             rs=d.get_data()*73;
  25.         }
  26.         void disp()
  27.         {
  28.             cout<<"\n Rupee is "<<rs;
  29.         }
  30. };
  31. int main()
  32. {
  33.     rupee r;
  34.     dollar d;
  35.     r=d;//convestion from one class to another
  36.     r.disp();
  37. }
  38.  
Add Comment
Please, Sign In to add comment