2014-10-12 53 views
-3

我搜索了很多,以清除以下錯誤,無法找到答案。 我收到以下錯誤。請幫助我的人在此先感謝stl C++錯誤:無法打開矢量頭文件,「;」預計

ERROR: unable to open vector headerfile, 
";" expected 
#include <iostream.h> 
#include <vector> 

template <typename T> 
class MyQueue 
{ 
std::vector<T> data; 
public: 
void Add(T const &); 
void Remove(); 
void Print(); 
}; 

template <typename T> void MyQueue<T> ::Add(T const &d) 
{ 
data.push_back(d); 
} 

template <typename T> void MyQueue<T>::Remove() 
{ 
data.erase(data.begin() + 0,data.begin() + 1); 
} 

template <typename T> void MyQueue<T>::Print() 
{ 
std::vector <int>::iterator It1; 
It1 = data.begin(); 
for (It1 = data.begin() ; It1 != data.end() ; It1++) 
cout << " " << *It1<<endl; 

} 
//Usage for C++ class templates 
void main() 
{ 
MyQueue<int> q; 
q.Add(1); 
q.Add(2); 

cout<<"Before removing data"<<endl; 
q.Print(); 

q.Remove(); 
cout<<"After removing data"<<endl; 
q.Print(); 
} 
+0

編譯器在尋找頭文件在哪裏?有一種全球性的設置指向正確的道路,也許這是錯誤的。 – 2014-10-12 06:48:19

回答

1

變化

#include <iostream.h> 

#include <iostream> 
1

#include <iostream> not <iostream.h>. 

難道你沒有得到任何錯誤,如「無法打開包含文件:'iostream.h':沒有這樣的文件或目錄」。