435,191 Members | 1,064 Online
Need help? Post your question and get tips & solutions from a community of 435,191 IT Pros & Developers. It's quick & easy.

# Member function redeclaration not allowed

 P: 2 So, below is code for a binary tree, the structure is referred to as TreeNode. I'm having some trouble separating what information goes into the TreeNode.h file and the TreeNode.cpp file. Here is the .h file Expand|Select|Wrap|Line Numbers #pragma once #ifndef TREENODE_H #define TREENODE_H #include  #include  class TreeNode{ private: std::string word; int count; TreeNode *left; TreeNode *right;   TreeNode() {}   public:     TreeNode(std::string word, int count, TreeNode *left, TreeNode *right);     void downtree(std::string s);     void printTree();     }; #endif     Here is the .cpp file Expand|Select|Wrap|Line Numbers #include  #include "TreeNode.h" #include  using namespace std;       TreeNode::TreeNode(std::string word, int count, TreeNode *left, TreeNode *right); {     downtree(word); } void TreeNode::downtree(std::string s){         if (word.compare(s)  > 0 ){         if (left == NULL) {           left = new TreeNode;         left->word = s;         left->count = 1;         left->left = NULL;         left->right = NULL;         }         else             {left.downtree(s);         }     }     else if (word.compare(s)  < 0 ){         if (right == NULL) {           right = new TreeNode;         right->word = s;         right->count = 1;         right->left = NULL;         right->right = NULL;         }         else{         right.downtree(s);         }     }     else if (word.compare(s)  == 0 ){         count++;     } }     The intent of this tree is to be able to take in a string and place it in the proper position. The error messages: Error 5 error C2761: '{ctor}' : member function redeclaration not allowed Error 6 error C2447: '{' : missing function header (old-style formal list?) Error 7 error C2228: left of '.downtree' must have class/struct/union Error 8 error C2228: left of '.downtree' must have class/struct/union Does anyone know the source of these error messages? I need a second pair of eyes on this. Thanks! Sep 24 '10 #1