错误:在'<'标记之前预期的构造函数,析构函数或类型转换

Bre*_*ent 1 c++

我一直在尝试最后20分钟搞清楚它为什么会抛出这个错误..

#include <GL/glut.h>
#include <vector>

// global width and height
int GW;
int GH;

// current mouse position in pixel coordinate
int x;
int y;

typedef struct myTriangle {
   float tx;
   float ty;
} myTriangle;

vector<myTriangle> container;
Run Code Online (Sandbox Code Playgroud)

代码抛出这个:

Transform.cpp:17:错误:在'<'标记之前的预期构造函数,析构函数或类型转换

Jef*_*ffW 5

在我看来,你没有指定vector的命名空间,也没有声明你正在使用std :: vector.试试这个:

std::vector<myTriangle> container;
Run Code Online (Sandbox Code Playgroud)