在我的头文件中,我有一个名为Arc
的自定义类,声明为
class Arc{
public:
Point start, end, centre;
//an arc is specified with its centre , starting point and end point
float radius, sweep, theta;
//radius of the arc and the angle enclosed by the arc are specified
int direction;
//whether the arc is formed in the clockwise direction or the anticlockwise direcn is specfied
Arc();
Arc(Point, Point, Point, int);
void draw();
// draws the arc on the GLUT canvas
int nextDirection(Point);
// finds the direction of the arc formed by joining the end point of this arc and a new point
};
我想创建这个自定义类的向量。我声明了一个这样的矢量:
extern vector<Arc> arcs;
此行给出以下4个错误。
error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'|
error: expected a type, got 'Arc'|
error: template argument 2 is invalid|
error: invalid type in declaration before ';' token|
我读到另一个答案,这样的声明需要我添加的类中的默认构造函数。但仍然会发生同样的错误
注意:使用g++
编译器在Ubuntu14.04上成功构建。但是当尝试使用mingw-g++
在Windows 8.1上构建Code :: Blocks时,会出现此错误。