C++ Compiler Error C2751 - What exactly causes it?
问题 I am wrestling with the C2751 compiler error and don't quite understand what exactly causes it. The following little code produces the error: #include <iostream> class A { public: A () { std::cout << "A constructed" << std::endl; }; static A giveA () { return A (); } }; class B { public: B (const A& a) { std::cout << "B constructed" << std::endl; } }; int main () { B b1 = B (A::giveA ()); // works B b2 (B (A::giveA ())); // C2751 B b3 (A::giveA ()); // works } Compiler output: