I have an array of pointers to a structure called a "table" (a structure called Node).
I declare an array as such in the class:
Node * table;
Then, in another method, I initialize the table:
this->table = new Node [this->length];
And everything works fine. this-> length is a valid entry, this-> table points to the correct array, etc. However, I am trying to change the value of the elements:
for(int i = 0; i < this->length; i++) { this->table[i] = new Node; }
Or even
for(int i = 0; i < this->length; i++) { this->table[i] = 0; }
And everything starts to bugger. Why can't I set these pointers to anything?
This is the error I get: 
(where line 15 is the line "this-> table [i] = new Node;").
I donβt like to place long code segments, so here is a shortened version of the code itself:
template <class T, class S> class HashMap { public: HashMap(); private: struct Node; Node * table; static const unsigned length = 100; }; template <class T, class S> HashMap<T, S>::HashMap() { this->table = new Node [HashMap::length]; for(int i = 0; i < HashMap::length; i++) { this->table[i] = new Node; } } template <class T, class S> struct HashMap<T, S>::Node { T value; S key; Node * next; };
No research that I do tells me what error is; any help is appreciated!
source share