我有两个文件,homework1.cc和homework1.h.
顶部homework1.cc是
#include <iostream>
#include <fstream>
#include <cstring>
#include <GL/glut.h>
#include "homework1.h"
using namespace std;
Run Code Online (Sandbox Code Playgroud)
而顶部homework1.h是
#ifndef _rt_H
#define _rt_H
#include <cmath>
#include <vector>
#include <list>
#include <GL/glut.h>
using namespace std;
Run Code Online (Sandbox Code Playgroud)
这是我用list的地方homework1.h
class surTriangle
{
float x;
float y;
float z;
list <int> surTriangles;
bool compareVertex(Vector3f anotherVec)
{
if(anotherVec[0] == x && anotherVec[1] == y && anotherVec[2] == z)
return true;
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译时homework.cc,编译器报告
homework1.cc:8:错误:在'使用'之前预期的unqualified-id
但是,当我删除#include <list>或上面的第三段代码成功编译.
你能帮我找一下问题是什么吗?
课后声明你需要一个分号.(类片段的最后一行homework1.h).否则使用被解释为标识符,如
class X {
} x;
Run Code Online (Sandbox Code Playgroud)