Ok, here is my thinking. I need myNodePool to be accessible everywhere, just like my bst tree. But i want myNodePool to "inside" of bst, i.e. if I have a var "bst tree" then to access myNodePool it would look something like this: tree.myNodePool[val].var. So I added "NodePool myNodePool" under the public definitions in bst.h - so do I have to do anything else with myNodePool inside of bst.cpp? Just by declaring it in bst.h should it call the default constructor for NodePool, correct?
I've added this code to node.cpp:
Node NodePool::operator (int indx)
if (indx >= SIZE || indx < 0)
sprintf(errStr, "%s %d: Index %d not in range 0 to %d", __FILE__, __LINE__, indx, SIZE);
sprintf(errStr, "%s %d: Index %d refers to a node on the freelist.", __FILE__, __LINE__, indx);
I think that I am getting myself really confused. When I asked my professor "Now would the default bst constructor be the one to create the new NodePool object?" he replied "Yes". However that just creates a local variable.
Node operator(int indx);
Now when I compile I am only getting this error:
37 bst.cpp expected primary-expression before "void"
int bst::insert (string word, int lineno)
// Check to see if the string is already in the BST
duplicate = search(word);
if(duplicate == -1)
// No duplicate found, get next available node
next = myNodePool.get(void); // line 37
myNodePool[next].value = word;
myNodePool[next].lineNumber = lineno;
myNodePool[next].used = true;