Why is my overloaded C++ constructor not called?

前端 未结 6 1749
暖寄归人
暖寄归人 2021-02-20 12:17

I have a class like this one:

class Test{
public:
  Test(string value);
  Test(bool value);

};

If I create an object like this:



        
6条回答
  •  悲哀的现实
    2021-02-20 13:12

    One way to circumvent this problem, is to provide another constructor taking a const char* and then converting explicitly to a std::string.

提交回复
热议问题