I was trying to store the class object in a file but as the class contains a vector of pointers which is causing a trouble because next time I am accessing the class I am able to fetch everything but this vector.
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;
}
};
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 is some class.
after storing this Node class in the file and then reading it. the fetchChildren function throws segmentation fault with the obvious reason. is there any way to store the object and not just the pointer.
Aucun commentaire:
Enregistrer un commentaire