std::list

World7th World7th 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
麻烦大家测试一下面的代码,不知道为什么崩溃,换成vector就不崩溃

//-------------g_variabletest.cpp-----------------------------

#include <list>
#include <string>
#include "test.h"

test g_test;

int main()
{
getchar();
return 0;
}

//------------test.h-------------------------------------
#include <list>
#include <vector>
#include <string>

class test
{
public:
test();
~test();

private:
static std::list<std::string> m_sList;
//static std::vector<std::string> m_sVec;


};

//-----------------test.cpp------------------------
#include <iostream>
#include "test.h"

std::list<std::string> test::m_sList;
//std::vector<std::string> test::m_sVec;

test::test()
{
std::list<std::string>::iterator it = m_sList.begin();
//std::vector<std::string>::iterator it = m_sVec.begin();

//for (; it != m_sVec.end(); it++)
for (; it != m_sList.end(); it++)
{
std::cout << "test" << std::endl;
}
}

test::~test()
{
}
...全文
评论 18
收藏 已收藏
分享
返回顶部
World7th
VC/MFC 16,550 成员 421,606 内容