问题描述
我试图将类对象存储在文件中,但是由于该类包含一个指针向量,这会造成麻烦,因为下次我访问该类时,我能够获取除该向量之外的所有内容。
typedef vector<pair<int,MBR *>> vppint;
class Node{
private:
int id;
int parentID;
int total_children;
MBR *mbr;
vppint children;
public:
vppint fetchChildren(){
return return this->children;
}
int totalChildren(){
return this->total_children;
}
};
MBR是某种课程。
将此Node类存储在文件中,然后读取它。 fetchChildren函数有明显的原因引发分段错误。有什么方法可以存储对象,而不仅仅是指针。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)