vc如何使用stl?

scklotz 2001-07-14 02:56:12
我做了个控制台程序,使用stl, 一切按照默认值。
#include "stdafx.h"
#include <list>

int main(int argc, char* argv[])
{
list<int> mylist;
return 0;
}
可编译时出现错误:错误如下:--------------------Configuration: test1 - Win32 Debug--------------------
Compiling...
test1.cpp
F:\Vc程序\stl\test1\test1.cpp(9) : error C2065: 'list' : undeclared identifier
F:\Vc程序\stl\test1\test1.cpp(9) : error C2062: type 'int' unexpected
Error executing cl.exe.

test1.exe - 2 error(s), 0 warning(s)

请教大虾指点。
...全文
237 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
scklotz 2001-07-14
  • 打赏
  • 举报
回复
谢谢你。真的很感谢你。
littleme741 2001-07-14
  • 打赏
  • 举报
回复
两种方法:
1。 在main()前加入语句using namespace std;
2。在使用stl相关的类之前加如std::修饰符
比如
std::list<int> mylist;
任选其一就可以了。

原因是因为std有名字空间的概念,关于名字空间详细可参看MSDN中namespace这个关键字。

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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