非常に明白な解決策があると確信している問題がありますが、わかりません。基本的には、私のヘッダーでクラス定義を行い、ソースファイルで実装しようとすると、クラスを再定義しているというエラーが表示されます。 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
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;
}
}
私は質問をした人と同じ問題がありました。しかし、変数はどこに置くのですか(クラスにはプライベートなのですか)? –