I have a vector that is made up of structures. I'm wondering how to read the data from each structure that is stored in the vector. Thanks for any help in advance.
Thanks, Rubiks14
I have a vector that is made up of structures. I'm wondering how to read the data from each structure that is stored in the vector. Thanks for any help in advance.
Thanks, Rubiks14
You should consider using a vector of pointers to your structs.Code:vector<myStruct>::const_iterator pos = myVector.begin(); for(; pos != myVector.end(); ++pos) { cout<<pos->dataMember<<endl; }
might sound dumb but what exactly does index represent?
EDIT: nevermind i figured it out...i have no idea why i didn't think of that before though...i probly need to take a break
Last edited by Rubiks14; 02-25-2006 at 08:56 PM.
>> You should consider using a vector of pointers to your structs.
Considering other options is not a bad idea, but storing struct instances directly should be the default. You would only store pointers if you had a specific reason (e.g. use of polymorphism or performance problems due to expensive copying). Pointers make the design more complicated so they should not be used unless necessary.