Answer to Question #180415 in C++ for VEER SINGH

Question #180415

Class to class conversion can be done in source as well as destination class. write a program to support this.


1
Expert's answer
2021-04-11T22:41:44-0400
#include <bits/stdc++.h>
using namespace std;

class Class_type_one {
   string a = "TutorialsPoint";
   public:
      string get_string(){
         return (a);
   }
   void display(){
      cout << a << endl;
   }
};

class Class_type_two {
   string b;
   public:
   void operator=(Class_type_one a){
      b = a.get_string();
   }
   void display(){
      cout << b << endl;
   }
};
int main(){
   Class_type_one a;
   Class_type_two b;
   b = a;
   a.display();
   b.display();
   return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS