初始化結構向量我初始化正常型載體是這樣的:用括號內的初始化列表
vector<float> data = {0.0f, 0.0f};
但我在使用結構代替普通型
struct Vertex
{
float position[3];
float color[4];
};
vector<Vertex> data = {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.0f}};
我得到錯誤could not convert '{{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.0f}}' from '<brace-enclosed initializer list>' to 'std::vector<Vertex>'
。這有什麼問題?