だから私は非常に明白な解決策があると確信している問題を抱えていますが、それを理解できないようです. 基本的に、ヘッダーでクラス定義を行い、ソース ファイルで実装しようとすると、クラスを再定義しているというエラーが表示されます。Visual C++ 2010 Express を使用します。
正確なエラー:「エラー C2011: 'ノード': 'クラス' 型の再定義」
以下にコード例を示します。
Node.h:
#ifndef NODE_H
#define NODE_H
#include <string>
class Node{
public:
Node();
Node* getLC();
Node* getRC();
private:
Node* leftChild;
Node* rightChild;
};
#endif
ノード.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;
}
}