摘要: 近日发现开发的一个程序有个指针被重复删除了,跟踪检查后发现是虚函数不够‘虚’导致重复删除造成的。请看实例代码#include"stdafx.h"#include<iostream>classBase{public:Base(){fun();}virtual~Base(){fun();}virtualvoidfun(){std::cout<<"Base::fun"<<std::endl;}};classSub:publicBase{public:Sub(){fun();}~Sub(){fun();}virtualvoid 阅读全文
posted @ 2012-08-20 15:23 胖胖熊 阅读(165) 评论(0) 推荐(0) 编辑
摘要: IntArray arrTest;arrTest.append(1);arrTest.append(1);arrTest.append(1);arrTest.append(1);arrTest.append(1);arrTest.append(1);IntArray other;arrayForeachT(arrTest, BD<int>(&IntArray::append, BST::ref(other), _1)); // OKarrayForeachT(arrTest, BD<int>(&IntArray::append, &other, 阅读全文
posted @ 2012-08-20 15:05 胖胖熊 阅读(189) 评论(0) 推荐(0) 编辑