我有一些 C++ 代码,其中我的 main.cpp 包含一个文件 SimpleGraph.h。当我尝试编译时,我得到:
In file included from main.cpp:9:
SimpleGraph.h:201: error: ISO C++ forbids declaration of ‘set’ with no type
SimpleGraph.h:201: error: invalid use of ‘::’
SimpleGraph.h:201: error: expected ‘;’ before ‘<’ token
然后它继续在其他行中出现类似的错误。此处指定的第 201 行是:
std::set<int> getConvexHullPoints() const {return convexHullPoints;}
我在 stackoverflow 上发现的类似错误通常似乎源于缺少的“std::”,但在这里它存在。我认识的其他人使用 SimpleGraph.h 和相同的编译器并且没有任何问题。那么这可能是我在 main.cpp 中调用它的方式吗?我在这里使用:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <vector>
#include "SimpleGraph.h"
using namespace std;
...then the main body of the program
任何帮助将不胜感激。
编辑:我只需要
#include <set>
正如 hmjd 和 KennyTM 所指出的,在 main.cpp 中。真是个笨蛋,抱歉浪费了你的时间。谢谢你帮我不要浪费我的。