【发布时间】:2020-06-28 17:45:56
【问题描述】:
写的类有什么问题,返回如下错误:
EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
当 operator= 被调用时。
class test
{
int x;
public:
test()
{
this->x=10;
}
test(const test& other)
{
this->x=other.x;
}
test& operator=(const test& other)
{
this->x=other.x;
}
};
【问题讨论】:
-
它与其他运营商合作吗?
-
你不是来自
operator=的return。那是UB。 -
@cigien 我怎么错过了!!非常感谢
标签: c++ class operator-overloading