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

Carlo Wood carlo at alinoe.com
Mon Feb 18 04:32:07 UTC 2002


On Tue, Feb 12, 2002 at 01:27:31PM +1030, Mark Phillips wrote:
> largeStructTy const& nextLs=largeStructList[0];
> for (int i=0; i<N; ++i) {
>   largeStructTy const& ls=nextLs;
>   nextLs=largeStructList[i+1];
>   // do stuff involving the reading of ls and nextLs
>   // ...
> }

int next=0;
for (int i=0; i<N; ++i) {
  largeStructTy const& ls=largeStructList[next];
  largeStructTy const& nextLs=largeStructList[(next=i+1)];
  // do stuff involving the reading of ls and nextLs
  // ...
}
-- 
Carlo Wood <carlo at alinoe.com>



More information about the tuxCPProgramming mailing list