Hi, just a quick question about vectos of structs here. If I have this struct:
Code:typedef struct _MyStruct { int Var1; int Var2; } MyStruct;
and I have this vector:
Code:vector<MyStruct> MyVectorOfStructs;
and we'll say I did this:
Code:MyStruct TempStruct; for ( int i=0; i<10; i++ ) // Just assigning values to the vector. { TempStruct.Var1=i; TempStruct.Var2=i; MyVectorOfStructs.push_back( TempStruct ); }
If I want to get MyVectorOfStructs fourth position Var1 (if you get me, it should be 5 or something), would I have to assign the fourth position of MyVectorOfStructs to a struct, and retrive the Var1 value from that, or is there a way I can directly retrive the value of the fourth position's Var1?
Thanks.
EDIT: I just wrote that down, didn't compile anything, so if there are errors, assume they're due to that.



LinkBack URL
About LinkBacks



)
Want to add some