Through class conversion, one can assign data that belongs to a particular class type to an object that belongs to another class type.
Let there be two classes ‘A’ and ‘B’. If we want to allocate the details that belong to class ‘A’ to an object of class ‘B’ then this can be achieved by –
B(object of class B) = A(object of class A)
where ‘=’ has been overloaded for objects of class type ‘B’.
Class conversion can be achieved by conversion function which is done by the use of operator overloading.
- Can a C++ class have an object of self type?
- std::any Class in C++
- std:: valarray class in C++
- Structure vs class in C++
- std::uniform_int_distribution class in C++
- std::hash class in C++ STL
- std::string class in C++
- Array class in C++
- Difference between namespace and class
- Virtual base class in C++
- How to implement our own Vector Class in C++?
- Friend class and function in C++
- C++ String Class and its Applications | Set 2
- C++ string class and its applications
- Simulating final class in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.