NL
2010-02-03 21:07:11 UTC
Hi,
A simple question, I'm sure, but I can't seem to find the answer. How
do modify the contents of a container in a for each construct? That
is, obtain a reference to the object in the container rather than a
temporary copy? (The code below _won't_ modify the "FooVector")
struct Foo {
int a;
}
vector<Foo> FooVector;
for each( Foo f in FooVector )
{
f.a = some_new_value;
}
Thanks,
NL
A simple question, I'm sure, but I can't seem to find the answer. How
do modify the contents of a container in a for each construct? That
is, obtain a reference to the object in the container rather than a
temporary copy? (The code below _won't_ modify the "FooVector")
struct Foo {
int a;
}
vector<Foo> FooVector;
for each( Foo f in FooVector )
{
f.a = some_new_value;
}
Thanks,
NL