Reputation: 19
I have a function in a common module(class) which takes a struct reference of vector type: The structure has an element which is of Vector type.
Please refer following code snippet:
bool getFrameInfo(ABC& abc);
struct ABC {
int numberOfFrames;
std::vector<XYZ> framInfo;
....
}
struct XYZ {
int size;
Position Pos;
...
}
I need to access and store members of struct XYZ in member variables or local variables in my class which calls the function defined in the common module to get frame information. Please suggest ways to access and store "XYZ" struct members so that I can use them repeatedly in my program to draw a frame.
Upvotes: 1
Views: 1030
Reputation: 73366
Example:
bool getFrameInfo(ABC& abc) {
abc.framInfo[0].size = 10;
// more code, where you return something somewhere
}
This will access your vector from abc
, then index its first element (I assume it exists), and access the size
field of the first struct of your vector. It stores 10 in its size
.
Upvotes: 2