A* operator/(A*, A*)‘ must have an argument of class or enumerated type

当在templete中重载+,/运算符时,按以上写法报错

这是全部代码:

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);

};

原因:不能重载指针运算符

应当改用 

(const A& a1 , const A& a2)

 

这个问题困扰了很久,在这里找到解答

c++ - must have an argument of class or enumerated type - Stack Overflowicon-default.png?t=M276https://stackoverflow.com/questions/33143380/must-have-an-argument-of-class-or-enumerated-type

posted @ 2022-06-19 17:04  Hello418  阅读(93)  评论(0编辑  收藏  举报