如何访问和存储向量类型的结构成员?

How to access and store struct members of vector type?

我在一个公共模块 (class) 中有一个函数,它采用向量类型的结构引用: 该结构有一个 Vector 类型的元素。

请参考以下代码片段:

bool getFrameInfo(ABC& abc);

struct ABC {
    int numberOfFrames;
    std::vector<XYZ> framInfo;
    ....
    }

    struct XYZ {
    int size;
    Position Pos;
    ...
    }

我需要在成员变量或局部变量中访问和存储struct XYZ的成员class,它调用公共模块中定义的函数来获取帧信息。 请建议访问和存储 "XYZ" 结构成员的方法,以便我可以在我的程序中重复使用它们来绘制框架。

示例:

bool getFrameInfo(ABC& abc) {
    abc.framInfo[0].size = 10;
    // more code, where you return something somewhere
}

这将从 abc 访问你的向量,然后索引它的第一个元素(我假设它存在),并访问你的向量第一个结构的 size 字段。它在 size.

中存储 10