2012-02-22 129 views
0

我在C++中有一些代碼,其中我的main.cpp包含一個SimpleGraph.h文件。當我嘗試編譯時,我得到:C++編譯器錯誤:ISO C++禁止聲明沒有類型的'set'

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;} 

類似的錯誤,我已經在計算器發現通常似乎從失蹤到幹「的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> 
在main.cpp中

,由hmjd和KennyTM指出。多麼虛榮,抱歉浪費你的時間。謝謝你幫助我不要浪費我的錢。

+1

請出示您更多的頭文件,該問題可能不是來自於那些線本身。 (你包括'',對不對?) – Mat 2012-02-22 11:39:13

+0

請使用那些不贊成的C頭文件退出。讓自己[一本好的C++書](http://jcatki.no-ip.org/fncpp/Resources)。 – 2012-02-22 11:42:17

回答

2

您需要#include <set> ..

1

您需要#include <set>才能使用std::set