C++为一个基类编写拷贝赋值运算符出现"!="无法与操作数匹配的问题


Quote& operator =(const Quote& rhs)
    {
        if (*this != rhs)
        {
            bookNo = rhs.bookNo;
            price = rhs.price;
        }
        std::cout << "Quote:copy =()" << endl;

        return *this;
    }

img


啥情况
请求各位帮忙!

if(this!=&rhs)

你只重载了赋值运算符
你这个类里有不支持==的复杂类型变量,整个类默认就不支持==方法,需要尔自己写