I tried the following code snippet in three different compilers (g ++, clang ++, CL.exe), and they all tell me that they cannot eliminate the ambiguous overloaded constructors. Now I know how I can change the constructor call so that it chooses one or the other (either make it explicit that the second argument is an unsigned value, or explicitly it).
However, I am curious why the compiler will try to choose between the constructors in the first place, given that one of the constructors is private, and the constructor is called in the main function, which should be outside the scope of the class,
Can someone enlighten me?
class Test { private: Test(unsigned int a, unsigned int *b) { } public: Test(unsigned int a, unsigned int b) { } }; int main() { Test t1 = Test(1,0);
source share