首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

STL有关问题

2012-02-13 
STL问题今天刚开始学,可是什么都不懂,在网上看到个例子,是list的,定义一个list,编译会出错...#includestr

STL问题
今天刚开始学,可是什么都不懂,在网上看到个例子,是list的,定义一个list,编译会出错...

#include   <string>
#include   <list>
int   main   (void)  
{
    list <string>   Milkshakes;
    return   0;
}

错误:

d:\my   project\list\list.cpp(5)   :   error   C2065:   'list '   :   undeclared   identifier
d:\my   project\list\list.cpp(5)   :   error   C2065:   'string '   :   undeclared   identifier
d:\my   project\list\list.cpp(5)   :   error   C2065:   'MilkShakes '   :   undeclared   identifier
d:\my   project\list\list.cpp(5)   :   warning   C4804:   '> '   :   unsafe   use   of   type   'bool '   in   operation
d:\my   project\list\list.cpp(5)   :   warning   C4552:   '> '   :   operator   has   no   effect;   expected   operator   with   side-effect

是怎么回事呢??刚开始看,什么都不懂...

[解决办法]
初学要靠书,不要靠网上的例子。
去买本《C++ Primer》,不要舍不得钱。
#include <list>
using namespace std;
int main (void)
。。。
[解决办法]
要加 using namespace std;

LZ 可以看一下 < <STL 源码剖析> >

热点排行