我有以下 foo 类成员。
foo &foo::bar() { return this; }
但我收到编译器错误。我做错了什么蠢事?
编译器错误(gcc):错误:从类型“foo* const”的临时类型对“foo&”类型的非常量引用进行无效初始化
this是一个指针。所以应该是return *this;
this
return *this;