So, I have a problem, and I'm sure there is a very obvious solution, but I just can not understand. Basically, when I try to execute class definitions in my headers and implementations in my source files, I get a message that I am redefining my classes. Using Visual C ++ 2010 Express.
Exact error: "Error C2011: 'Node': overriding class type"
Sample code below:
Node.h:
#ifndef NODE_H #define NODE_H #include <string> class Node{ public: Node(); Node* getLC(); Node* getRC(); private: Node* leftChild; Node* rightChild; }; #endif
Node.cpp
#include "Node.h" #include <string> using namespace std; class Node{ Node::Node(){ leftChild = NULL; rightChild = NULL; } Node* Node::getLC(){ return leftChild; } Node* Node::getRC(){ return rightChild; } }
source share