草庐IT

deletedConstructorTest

全部标签

c++ - 已删除的默认构造函数被标识为歧义错误中的候选者

当尝试删除默认构造函数并提供一个带有默认参数的新构造函数(因此仍然能够默认构造对象)时,我收到来自g++的歧义错误。classThing{public:Thing()=delete;Thing(intarg=0):arg(arg){}private:intarg;};intmain(int,char**){Thingthing;return0;}编译错误如下:$g++deletedConstructorTest.C-std=c++11deletedConstructorTest.C:Infunction"intmain(int,char**)":deletedConstructorTe