[Exceptional C++ Style] Item 17 - Encapsulation

Balog Pal pasa at lib.hu
Mon Dec 20 15:49:10 EST 2004


[repost]
> So you could write:
>
> const SomeData& Case1::GetSomeData()const
> {
>     return SomeData(myInternalRep);
> }

Yeah that is the problem: you can't return a temporary/rvalue by reference.
To do that kind of stuff the getter should return by value.




More information about the Effective-cpp mailing list