2014-10-12 51 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':没有这样的文件或目录”。