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.
Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.
- Can a C++ class have an object of self type?
- lseek() in C/C++ to read the alternate nth byte and write it in another file
- Rotation of a point about another point in C++
- C++ program to append content of one text file to another
- Check if a string can be formed from another string using given constraints
- Reverse the content of a file and store it in another
- Data type of character constants in C and C++
- RTTI (Run-time type Information) in C++
- Type difference of character literals in C and C++
- Function overloading and return type
- Type of 'this' pointer in C++
- const_cast in C++ | Type Casting operators
- Data Type Ranges and their macros in C++
- Conversion of Struct data type to Hex String and vice versa
- Array Type Manipulation in C++
- Bool data type in C++
- Comparison of boolean data type in C++ and Java
- C++ set for user define data type
- What is the size_t data type in C?
- Is there any need of "long" data type in C and 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.