编译错误:' - >'的基本操作数有非指针类型'令牌'

qre*_*eam 6 c++

在尝试编译我的c ++代码时,我得到了标题中提到的错误.我无法理解我在这里做错了什么.

编译器在执行bool operator==(Token )函数时遇到问题.我认为这是超载运营商的方式.

任何线索,为什么编译器不喜欢我指的 this->terminal还是this->lexeme

class Token {
    public:
        tokenType terminal;
        std::string lexeme;
        Token *next;

        Token();
        bool operator==(Token &t);
    private:
        int lexemelength, line, column;
};

bool Token::operator==(Token &t) {
    return ((this->terminal == t->terminal) &&
            (this->lexeme == t->lexeme));
}
Run Code Online (Sandbox Code Playgroud)

Qix*_*Qix 11

仔细看看你的类型.t是一个引用(Token &t)意味着它必须使用点运算符(.)引用.

引用不是指针; 将它们视为已经取消引用的指针而不将实际对象放在堆栈上(通过引用传递).