// stlTest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <list>
using namespace std;
struct Info
{
int a;
char str[255];
};
class AClass
{
static AClass()
{
}
public:
static std::list <int> dList;
static void ProInfo()
{
int a;
dList.push_back(a);
}
};
list<int> AClass::dList;
int _tmain(int argc, _TCHAR* argv[])
{
DClass the;
the.ProInfo();
return 0;
}
今天写一个类中需要共享一个STL链表,发现VS2005中不能用static的list链表。
因为VS2005不支持静态构造函数,而此STL的的类不能作为静态变量使用,原来是静态变态需要在初始化。
感谢zhykzhykzhyk 的回复,才使我找到了原因。
看来得好好习一本STL的书看一看了。