我的一个list要做push_back操作,可是push_back没反应?大家帮我看看。急!解决了再加100.typedef struct TagContactItem
{
int iID;}TagContactItem;
typedef std::list<TagContactItem> TagContactItems; TagContactItems aTagContactItems;void fun(TagContactItems& aTagContactItems)
{
TagContactItem stContactItem;
for(int i = 0 ; i < 5; i++)
{
stContactItem.iID = i;
::MessageBox(NULL,"1","1",1);
aTagContactItems.push_back(stContactItem);//这句没响应,运行到这就没了。
::MessageBox(NULL,"2","2",1);
}}
{
int iID;}TagContactItem;
typedef std::list<TagContactItem> TagContactItems; TagContactItems aTagContactItems;void fun(TagContactItems& aTagContactItems)
{
TagContactItem stContactItem;
for(int i = 0 ; i < 5; i++)
{
stContactItem.iID = i;
::MessageBox(NULL,"1","1",1);
aTagContactItems.push_back(stContactItem);//这句没响应,运行到这就没了。
::MessageBox(NULL,"2","2",1);
}}
解决方案 »
- 我打开一个网页后,然后触发axWebBrowser3_DocumentComplete事件,为何有时候该函数会调用2次?
- 怎样将所选目录下的子文件全显示在List box里?
- 关于CScrollView的一个简单问题,100分,请大侠指教!
- 急急急!!!小妹想请教各位这个弱智的问题!!望赐教!!!
- 关于HTTP请求头重新开个贴子
- 怎么看了com的书,还是不知道怎么编com
- 跪求bundschecker v9.0.2的vs2008下C1126: automatic allocation exceeds 2G的补丁。
- mfc ole拖拽问题
- 在MFC中如何画线?
- 有哪位大侠能给我一些关于设计任务书方面的资料?一定给分!
- 关于udp和tcp难以理解的问题
- WSARecv如果一次失败, 下次调用还能不能继续收之前那个失败的包?
typedef struct TagContactItem
{
int iID;}TagContactItem;
typedef std::list<TagContactItem> TagContactItemspublic:
TagContactItems m_ContactItems;
void FillContactItems(TagContactItems& aTagContactItems);.cpp 文件的代码:
void main()
{
fun(this->ContactItems);
}
void fun(TagContactItems& aTagContactItems)
{
TagContactItem stContactItem;
for(int i = 0 ; i < 5; i++)
{
stContactItem.iID = i;
::MessageBox(NULL,"1","1",1);
aTagContactItems.push_back(stContactItem);//这句没响应,运行到这就没了。
::MessageBox(NULL,"2","2",1);
}}
不过,如果list保存的是类对象不是很好,那样需要实现深拷贝。
建议保存指针。
typedef std::list<TagContactItem> TagContactItems;
变更为
typedef std::list<TagContactItem*> TagContactItems;
{
fun(this->ContactItems);
}this指针哪里的。
LZ的代码我也进行了测试,可以正常运行。
因为现在这样可能会涉及到深拷贝的问题, 所以改成指针的方式来维护试试.
运行到push_back,就停止了!
学习中。给顶一下。
[/Quote]
TagContactItems m_ContactItems; this->m_ContactItems;