Writing a 2d vector of objects to a file?

Hello everyone,

I have a 2d vector of objects that I need to write to a file and then read back from it later on. Can anyone please provide me information on how to go about it? Details of my 2d vector are as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// 2d array of nodes.
vector<vector<Node *>> _node_array;

// The Node class is as follows:
class Node {
public:
	bool _type;

	enum Status {
		open,
		close,
		neutral
	};
	Status _status; 

	int _grid_val;
	float _w, _l;
	Vector3 _position;

	Node *_prv_node;
	Node *_neighbors[8];

	Node(vector3 pos, float w, float l);
	~Node();

	bool contains(float x, float y);
};


Let me know if you require more information. Any help would be greatly appreciated! Thank you!
Overload the << and >> operators for your class, then iterate through the vector elements and print them to the file, reading would be something similar, you may want to store the vector sizes at the beginning of the file so you can know them when reading back
Topic archived. No new replies allowed.