Effective C++ Ed. 3rd: Item 28. Avoid returning "handles" to object internals.

While returning internal handles from a member function, consider
  • returning const object. This results in read-only access of the returned parameter.
The problem with dangling references will still remains. So it's better to avoid returning reference, pointer or iterators from a function. This would minimize dangling handles and also might provide better encapsulation in case of member functions.

prev | next
Cheers and try hosting at Linode.

No comments:

Post a Comment