Conversion Between the built-in types of C ++ and user-defined types
There are two main ways to convert the two types. The first is to convert the built-in type to the User-Defined type. Here, we take the int type conversion to the class type object as an example, second, convert the class type to the int type.
The former relies on conversion constructors, and the latter relies on custom type conversion functions.
1. Conversion Constructor
Ii. type conversion Constructor
# Include
Using namespace std; // The conversion constructor has only one parameter, but sometimes the constructor of this parameter not only plays a role in type conversion but also plays a role in constructor, however, only one constructor has a similar double identity. In this case, the default copy constructor class Trans {private: int m_data; public: trans (const Trans & t) {cout <"Copy Test Obj:" <