First I have three files. TreeNode.h, TreeNode.cpp, and animalGame.cpp. In animalGame I ask to get the item from a class instance of TreeNode named root. However it throws an error of "request for member 'getItem' in 'root', which is of non-class type 'TreeNode*'" I'm confused as I clearly declared it as a TreeNode 4 lines above. Can anyone help as to why this error is appearing?
Here is the code (snippets)
""""""""""""AnimalGame.cpp""""""""""""""
TreeNode *root = new TreeNode("Penguin");
while (true){
startStatement();
question();
cout << root.getItem() << endl;
See that's the code I had before. I changed it to what you wrote and now it's giving me this error: "multiple definition of `TreeNode::TreeNode(std::string, TreeNode*, TreeNode*)"
I finally got it working...I'm not sure why it works now but I got rid of the TreeNode.cpp file and put the implementation into the header.
"""""""""""""""TreeNode.h"""""""""""""""
class TreeNode{