What is a converting constructor in C++ ? What is it for?
问题 I have heard that C++ has something called "conversion constructors" or "converting constructors". What are these, and what are they for? I saw it mentioned with regards to this code: class MyClass { public: int a, b; MyClass( int i ) {} } int main() { MyClass M = 1 ; } 回答1: The definition for a converting constructor is different between C++03 and C++11. In both cases it must be a non- explicit constructor (otherwise it wouldn't be involved in implicit conversions), but for C++03 it must