I am working on a C++ project right now, and I was wondering if it is possible to make an array of Nodes.
I have created a Node class, which contains data variables:
string Element
Node* next
then it has accessors and mutators and such.
Then I am trying to create an array in another class, where each position in the array contains a pointer to a Node.
I tried doing it like this:
Node* Array[10];
and then in the constructor
for(int x=0; x<10; x++){
Array[x]=new Node();
}
That doesn't work. It gives me a fatal error.
I feel so rusty on using pointers
I have created a Node class, which contains data variables:
string Element
Node* next
then it has accessors and mutators and such.
Then I am trying to create an array in another class, where each position in the array contains a pointer to a Node.
I tried doing it like this:
Node* Array[10];
and then in the constructor
for(int x=0; x<10; x++){
Array[x]=new Node();
}
That doesn't work. It gives me a fatal error.
I feel so rusty on using pointers