VC是否支持STL?
请问VC是否支持STL,我用的是VC6.0,想编译一个调用了STL中list容器的程序,结果出错,说是缺少一个存储类的指定?难道list<>中需要两个参数吗?结果看到CRT中的list倒是需要两个参数的,CRT和STL不是一回事吧?怎么才能让VC支持STL呢?
请指教!
问题点数:20、回复次数:11Top
1 楼linxiao()回复于 2002-05-21 13:10:45 得分 0
当然支持啊Top
2 楼linxiao()回复于 2002-05-21 13:11:59 得分 0
#include <list>
#include <iostream>
using namespace std ;
typedef list<int> LISTINT;
void main()
{
int rgTest1[] = {5,6,7};
int rgTest2[] = {10,11,12};
LISTINT listInt;
LISTINT listAnother;
LISTINT::iterator i;
// Insert one at a time
listInt.insert (listInt.begin(), 2);
listInt.insert (listInt.begin(), 1);
listInt.insert (listInt.end(), 3);
// 1 2 3
for (i = listInt.begin(); i != listInt.end(); ++i)
cout << *i << " ";
cout << endl;
// Insert 3 fours
listInt.insert (listInt.end(), 3, 4);
// 1 2 3 4 4 4
for (i = listInt.begin(); i != listInt.end(); ++i)
cout << *i << " ";
cout << endl;
// Insert an array in there
listInt.insert (listInt.end(), rgTest1, rgTest1 + 3);
// 1 2 3 4 4 4 5 6 7
for (i = listInt.begin(); i != listInt.end(); ++i)
cout << *i << " ";
cout << endl;
// Insert another LISTINT
listAnother.insert (listAnother.begin(), rgTest2, rgTest2+3);
listInt.insert (listInt.end(), listAnother.begin(), listAnother.end());
// 1 2 3 4 4 4 5 6 7 10 11 12
for (i = listInt.begin(); i != listInt.end(); ++i)
cout << *i << " ";
cout << endl;
}
Program Output is:
1 2 3
1 2 3 4 4 4
1 2 3 4 4 4 5 6 7
1 2 3 4 4 4 5 6 7 10 11 12
Top
3 楼aileen_long(期待2002)回复于 2002-05-21 13:12:27 得分 0
VC6不支持所有的STL元素,但list还是支持的。把你的代码和错误贴出来看看!Top
4 楼jeffchen(Jeff)回复于 2002-05-21 13:14:44 得分 0
支持,但在使用时需要指定名字空间,using namespace std或者std::XXXXXXXTop
5 楼tigerVC(Tiger.Z)回复于 2002-05-21 13:20:49 得分 0
如果代码没有问题,看一下你的编译设置有没有错。Top
6 楼x_xy(sunny)回复于 2002-05-21 13:32:09 得分 0
using namespace std竟然也不支持?
#include <list>
using namespace std
class Administrator
{
public:
Administrator();
。。。
结果说是:
error C2143: syntax error : missing ';' before '<class-head>'Top
7 楼x_xy(sunny)回复于 2002-05-21 13:33:03 得分 0
编译设置需要怎么改?Top
8 楼Q_O()回复于 2002-05-21 13:44:43 得分 0
检查一下再不是差个“}”Top
9 楼aileen_long(期待2002)回复于 2002-05-21 13:49:00 得分 20
using namespace std // 编译器不是已经告诉你少了分号嘛Top
10 楼x_xy(sunny)回复于 2002-05-21 14:15:57 得分 0
呵呵,我真蠢,谢谢!Top
11 楼littlecatie(cool)回复于 2002-05-21 14:34:26 得分 0
STL是标准c++中的,VC当然支持Top




