必须具有类或枚举类型的参数

must have an argument of class or enumerated type

本文关键字:枚举 类型 参数      更新时间:2023-10-16
class mSet
{
    private:
        mSet *next;
        int element;
    public:
        mSet();
        mSet(int n);
    friend ostream& operator<< (ostream&, mSet*);
    friend mSet* operator+ (mSet*, mSet*);
    friend mSet* operator/ (mSet*, mSet*);
    mSet* operator= ( mSet* b);
};

我想重载+和/操作符,但我有这个错误:'mSet* operator/(mSet*, mSet*)'必须有一个类或枚举类型的参数

是否尝试添加两个指针?

我认为你应该写

friend mSet& operator+ (const mSet&, const mSet&);