Lars Gullik Bjønnes wrote:

> | What happens if the result is stored in yet another reference and the
> | function is invoked several times?  -> Nasty problems!
> 
> |     const string &ref1 = foo1.name();
> |     const string &ref2 = foo1.name();
> 
> |     if ( ref1 == ref2 )  /* ref1 == ref2!!! */
> 
> I see...
> No, not a real problem.
> the reference is to the static string, not to the allocated memory
> inside the static string.

Well, there is no memory access problem but is the programmer aware that 
ref1 changes if the method is called another time? Sometimes, you don't 
even notice that the method in called in between.

Michael


Reply via email to