我有两个文件,homework1.cc
和 homework1.h
.
顶部homework1.cc
是
#include <iostream>
#include <fstream>
#include <cstring>
#include <GL/glut.h>
#include "homework1.h"
using namespace std;
和顶部在homework1.h
是
#ifndef _rt_H
#define _rt_H
#include <cmath>
#include <vector>
#include <list>
#include <GL/glut.h>
using namespace std;
这是我使用 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;
}
}
当我尝试编译 homework.cc
,编译器报告
homework1.cc:8: error: expected unqualified-id before ‘using’
但是,当我删除 #include <list>
时或上面的第三段代码编译成功。
你能帮我找出问题所在吗?
最佳答案
类声明后需要一个分号。 (homework1.h
类片段的最后一行)。否则 using 被解释为标识符,如
class X {
} x;
关于c++ - 编译器报告 : error: expected unqualified-id before ‘using’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8347504/