运算符重载,operator =在类中“不命名类型”

时间:2014-07-11 06:37:36

标签: c++ operator-overloading

class GridElem {
public:
    GridElem();
    ~GridElem();
    GirdElem &operator=(const char _idata);
    friend char operator-(const GridElem &lhs, const char rhs);
private:
    char _data;
};

inline char operator-(const GridElem &lhs, const char rhs) {
    return lhs._data - rhs;
}

我不明白,我已经在GridElem.cpp

中实现了它
GirdElem& GridElem::operator=(const char _idata) {
    _data = _idata;
    return *this;
}

我的配置有什么问题,或者你能发现错误吗?

1 个答案:

答案 0 :(得分:4)

您在返回类型

中编写了GirdElem而不是GridElem