Here is a fake code sample
vector<Fred> gFred;
{
// init gFred
Fred &fred = gFred[0];
size_t z = 0;
do
{
fred = gFred[z];
// do odd processing with fred
z++;
}
while (fred.lastElementInSet == 0);
}
The thing that caught my attention was the fact that gFred[0] was being overwritten. This leads me to think that rather than init fred as a reference to a new element,
fred = gFred[z];
What is actually happening is that gFred[1] is overwriting gFred[0].
I'm thinking the correct thing to do here, is whap myself upsida head a few times, and turn this into a pointer implementation and move on with my life.
Have I diagnosed this correctly? or do I need more education?