#include <iostream> using namespace std; class TestClass{ public: TestClass(){ cout << "constructor" << endl; } TestClass(int a){ cout << "constructor " << a << endl; } }; class TestClass2{ public: TestClass2(){ cout << "constructor" << endl; } explicit TestClass2(int a){ cout << "constructor " << a << endl; } }; int main(){ TestClass t; TestClass t1 = 6; TestClass2 t2; TestClass2 t2 = 7;//编译通不过了~~~ cout << "letben" << endl; system("pause"); }
参见:
http://baike.baidu.com/link?url=ZdpF1NVfUtlRZHDNbN3RWRjBDzkOSzMWojBJs7RAqVkzVKr8qCC62DhY2FoA7MqopOnG3L13Pi3eARBCLC_QLK