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.

Recommended Answers

All 4 Replies

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

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.

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

oh okay, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.