0

I have to make an array of Nodes.
I have #include "Node.h" as my header file
and then in main I am writing the following code

Node[] Node_array = new Node[];

but then I am getting errors referring to the above line:

error C2143: syntax error : missing ';' before '['
error C3409: empty attribute block is not allowed
error C2146: syntax error : missing ';' before identifier 'Node_array'
error C2065: 'Node_array' : undeclared identifier

Will appreciate early reply.

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by achieve_goals
0

Try Node *Node_array = new Node[5]; or Node *Node_array = new Node[someNumberOfNodesYouWant];

0

Thanks for reply.

Now I am using Node Node_array[50]; and its working, but now I have a different question.
How do we check it the node is null, like i want to check if Node_array is null and have to add some data to it.
How should I do that?

Really appreciate it.

0

Your default Node constructor makes sure it is empty (in a way the rest of your Node class will recognise).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.