[Exceptional C++ Style] Item 17 - Encapsulation

Balog Pal pasa at lib.hu
Mon Dec 20 11:06:16 EST 2004


> 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