vc中无法使用stl,无法编译通过~~~

crab_hn 2003-08-21 09:11:58
#include <deque>

deque<int> a_line;
void main()
{
a_line.push_back(1);
}

--------------------Configuration: DS - Win32 Debug--------------------
Compiling...
test.cpp
g:\我的代码\data_structure\stl\test.cpp(3) : error C2143: syntax error : missing ';' before '<'
g:\我的代码\data_structure\stl\test.cpp(3) : error C2501: 'deque' : missing storage-class or type specifiers
g:\我的代码\data_structure\stl\test.cpp(3) : error C2143: syntax error : missing ';' before '<'
g:\我的代码\data_structure\stl\test.cpp(6) : error C2065: 'a_line' : undeclared identifier
g:\我的代码\data_structure\stl\test.cpp(6) : error C2228: left of '.push_back' must have class/struct/union type
Error executing cl.exe.
...全文
61 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
aflyinghorse 2003-08-21
  • 打赏
  • 举报
回复
#include <deque>
using namespace std;
deque<int> a_line;
void main()
{
a_line.push_back(1);
}
lemon520 2003-08-21
  • 打赏
  • 举报
回复
所有的STL都是包含在std名字空间中的!
jyfcsdn 2003-08-21
  • 打赏
  • 举报
回复
建议你看看名称空间的内容
lemon520 2003-08-21
  • 打赏
  • 举报
回复
看看名字空间的解释吧!你就知道了!
jyfcsdn 2003-08-21
  • 打赏
  • 举报
回复

deque<int> a_line;
这句之前加上
using namespace std;

或者
std::deque<int> a_line;

deque存在与名字空间std;
不加using namespace std;程序不知道的。


lemon520 2003-08-21
  • 打赏
  • 举报
回复
在#include<deque>
后面加!
crab_hn 2003-08-21
  • 打赏
  • 举报
回复
为什么呢?
lemon520 2003-08-21
  • 打赏
  • 举报
回复
加上 using namespace std;
就可以了!

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧