gpt4 book ai didi

c++ - 如何访问结构中定义的变量

转载 作者:行者123 更新时间:2023-11-27 23:17:12 25 4
gpt4 key购买 nike

struct POINT3DID 
{
unsigned int newID;
float x, y, z;
};

typedef std::map<unsigned int, POINT3DID> ID2POINT3DID;

ID2POINT3DID m_i2pt3idVertices;

谁能告诉我如何使用 m_i2pt3idVertices 访问变量 x、y 和 z

最佳答案

m_i2pt3idVertices 是用于存储POINT3DID 对象的容器。它单独没有成员变量 xyz。不过,您可以将 POINT3DID 放入其中:

m_i2pt3idVertices[0] = POINT3DID(); // Put a POINT3DID into key 0

m_i2pt3idVertices[0].x = 1.0f; // Assign x for key 0
m_i2pt3idVertices[0].y = 2.0f; // Assign y for key 0
m_i2pt3idVertices[0].z = 3.0f; // Assign z for key 0

关于c++ - 如何访问结构中定义的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15652287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com