[LC++]can't seem to use reference

Carlo Wood carlo at alinoe.com
Thu Feb 21 03:53:31 UTC 2002


On Wed, Feb 20, 2002 at 12:25:42PM +1030, Mark Phillips wrote:
> Or actually, I could do:
> 
> for (largeStructTy const* lsPr=&largeStructList[0]; 
>     lsPr<&largeStructList[N];) {
>   largeStructTy const& ls(*lsPr);
>   ++lsPr;
>   largeStructTy const& nextLs(*lsPr);
>   // do stuff involving the reading of ls and nextLs
>   // ...
> }
> 
> How would the compiler deal with this?  nextLs and lsPr could
> be the same register, but would the compiler do this?

That won't work, you'd have just one variable,
ls and nextLs are the same!

-- 
Carlo Wood <carlo at alinoe.com>



More information about the tuxCPProgramming mailing list