};
//This is declared later:
Flight f;
Node *n;
n = (Node*)malloc(sizeof(Node));
n-> next = start;
n-> g = f;
n-> num = flightnum;
start = n;
//As you can see I am trying to create an instance of the flight class in the Node but currently the program stops responding. I have included all the information to go into the flight class in another method.
Thanks
You are also new to this site. In the future, these sorts of questions belong on the Beginner forum. And for this post, please edit it and put [code] tags around the code so that it is nicely formatted.
The first problem is that you are using malloc in a C++ program. Abandon it forever. The reason is that malloc does not call constructors, so you have an uninitialized members (num and g) in your node. And then you try to assign to these objects. Bad things happen. You need to use "new" instead.
I almost laughed. Almost. It was very close.
As for forum, it is called beginners for a reason, and this does look like beginnerish work, but I don't personally draw a difference. (Unless you double post. I once even saw a triple post, as pointed out by chrisname some time ago.)
Yeah, stop using malloc. I have no idea how malloc works, so I can't help you on that (I hardly ever use the c libraries) but I can show you the essentials of new. sometype ptr = new sometype;
New dynamically allocates memory for a variable of type sometype, and returns the address. I remember something about the difference between operator new and something else but it's not important for any beginner. You can access the newed data probably the same way you access malloc'd stuff. delete ptr;
After malloc-ing, you need to free(). Same deal with new. The delete operator serves this purpose.
More: http://www.cplusplus.com/doc/tutorial/dynamic/