trouble with pointers

Hi,
Ive got a struct called Node that contains, among other things, a pointer to a vector of pgm objects. (pgm is a class i've created)

1
2
3
4
5
6
7
struct Node
{
	int label;
	vector <pgm> *ptr;
	Node* lessNode;
	Node* moreNode;
};


in another class, i create a vector and a Node and am having trouble assigning the pointer in the Node to point to my new vector.

1
2
3
vector <pgm> lessData;	
       Node* left;
	left->ptr=&lessData;


This all compiles ok, but the last line in the code above causes a segmentation fault. Any clues as to what i'm doing wrong here?
Cheers.

I should mention Node is declared on its own in Node.h and has no idea what pgm is. including pgm.h in node.h makes no change to the problem.
Last edited on
You haven't created a new node yet.
Node *left = new Node;
Thanks mate, I need to do more coding, I should have picked that up.
Topic archived. No new replies allowed.