程序如下:
#include<list.h>
#include<string.h>
#include<iostream.h>
using namespace std;
typedef list<string> LTSTSTR;
void main(void)
{
LTSTSTR test;
test.push_back("back");
test.push_front("middle");
test.push_front("front");
cout<<test.front()<<endl;
cout<<test.back()<<endl;
test.pop_front();
test.pop_back();
cout<<test.front()<<endl;
}
编译错误如下:
c:\program files\microsoft visual studio\vc98\include\list.h(37) :error C2146: syntax error : missing ; before identifier Length
c:\program files\microsoft visual studio\vc98\include\list.h(37) : error C2501: DWORD : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\list.h(37) : error C2501: Length : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\list.h(53) : error C2146: syntax error : missing ; before identifier GetPrevLink
c:\program files\microsoft visual studio\vc98\include\list.h(53) : error C2433: WINAPI : inline not permitted on data declarations
c:\program files\microsoft visual studio\vc98\include\list.h(53) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
ls.exe - 6 error(s), 0 warning(s)
#include<list>
#include<string>
#include<iostream>
using namespace std;
typedef list<string> LTSTSTR;
void main(void)
{
LTSTSTR test;
test.push_back("back");
test.push_front("middle");
test.push_front("front");
cout<<test.front()<<endl;
cout<<test.back()<<endl;
test.pop_front();
test.pop_back();
cout<<test.front()<<endl;
}
搂主换个编译器看看,代码应该没有问题
添一句:
#pragma warning(disable:4786)
头文件包领含的时候不要.h,试一下看能不能行