如何解决列表内存问题?
数据.h
class Data {
public: static Data * instance ;
private:
list<int> preVar;
static Data * createData() ;
};
数据.cpp
Data * Data::instance = Data::createData();
Data::Data() { }
Data * Data::createData(){
Data * tmp = (Data*)malloc(sizeof(Data));
tmp->preVar.clear(); // ERROR
return tmp;
}
调试点是 (error) int list.tcc : __cur = static_cast<_Node*>(__cur->_M_next);