->带有引用变量的运算符?(C++)

-> operator with a reference variable? (C++)

本文关键字:运算符 C++ 变量 引用 gt      更新时间:2023-10-16

是否有任何情况使用 ->带有参考变量/对象的运算符?

typedef ABC::Derived<Tmplt> THandle;
THandle m_oNew;    
m_oNew->m_u16GetState();    // This is the function call. Here "->" is used.

这是类"派生"和函数定义:

template<class T>
class Derived;
class AnotherClass
{
    friend class Derived;
    inline AnimState m_u16GetState () const
    {
        return m_u16State;
    }
};

如果使用x-> y,然后x必须a)成为指针变量或b)' ->'运算符必须超载x

的类型