Return reference from class to this.

Posted by Thomas on Stack Overflow See other posts from Stack Overflow or by Thomas
Published on 2010-04-12T11:30:54Z Indexed on 2010/04/12 11:33 UTC
Read the original article Hit count: 196

Filed under:
|
|
|

Hi,

I have the following member of class foo.

foo &foo::bar()
{
   return this;
}

But I am getting compiler errors. What stupid thing am I doing wrong?

Compiler error (gcc): error: invalid initialization of non-const reference of type 'foo&' from a temporary of type 'foo* const'

© Stack Overflow or respective owner

Related posts about c++

Related posts about this