我想知道在 C++ 中使用“this”来引用类成员而不是不使用它有什么好处吗?
例如...
class Test
{
public:
Test();
void print_test()
{
std::cout << this -> m_x // Using 'this'
<< endl;
std::cout << m_x // Rather than referencing 'm_x' this way
<< endl;
}
private:
int m_x;
int m_y;
};