error: expected primary-expression before ']' token with struct
error: expected primary-expression before ']' token with struct
struct Point
{
int x, y;
};
int Height[ Point ];
当我尝试声明一个内部类型为 "Point" 的新向量时出现此错误。错误是
error: expected primary-expression before ']' token
在最后一行(使用 int Height....)
int Height[ Point ];
表示创建一个名为 Height
的 int
类型的数组,其元素数等于 Point
。这不是你想要的。要制作任何 Point
个对象的数组,您可以使用 Point height[some_constant_number]
。如果您需要动态数组,请使用向量:std::vector<Point> points;
struct Point
{
int x, y;
};
int Height[ Point ];
当我尝试声明一个内部类型为 "Point" 的新向量时出现此错误。错误是
error: expected primary-expression before ']' token
在最后一行(使用 int Height....)
int Height[ Point ];
表示创建一个名为 Height
的 int
类型的数组,其元素数等于 Point
。这不是你想要的。要制作任何 Point
个对象的数组,您可以使用 Point height[some_constant_number]
。如果您需要动态数组,请使用向量:std::vector<Point> points;