我有两个像这样重载的构造函数,问题是输入了错误的构造函数重载:
class Param
{
Param(
const std::string& name,
const MyVariant& variant = MyVariant()
const std::string& desc = std::string(""),
bool b1 = true,
bool b2 = true )
:
mName(name),
mValue(variant),
mDesc(desc),
mB1(b1),
mB2(b2) {}
Param(
const std::string& name,
const MyVariant& variant,
bool b1)
:
mName(name),
mValue(variant)
mB1(b1) {}
private:
std::string mName;
MyVariant mValue;
std::string mDesc;
bool mB1;
bool mB2;
};
Param p("name",4,"desc"); // this enters the second constructor, not the first why ?