I get the following error:
Node.h:9: error: redefinition of 'class Node'
Node.h:8: error: previous definition of 'class Node'
When I compile my program. I cannot understand why it pops up since I have used hedder guards.
Node.h:9: error: redefinition of 'class Node'
Node.h:8: error: previous definition of 'class Node'
When I compile my program. I cannot understand why it pops up since I have used hedder guards.
Code:
#ifndef Node_H
#define Node_H
#include <iostream>
using namespace std;
//class node has four fields: type, child1, child2 and parent. The type is -1 if it is a inner node, 0 if it is the root and a positive number (cooresponding to the item it represent) if it is a leaf. The leaves functions eighter returns or changes it fields.
class Node{
private:
int type_;
int inter1_;
int inter2_;
Node* child1_;
Node* child2_;
Node* parent_;
public:
Node(Node* n1, Node* n2, int t);
int getInter1(){
return inter1_;
}
int getInter2(){
return inter2_;
}
void setInter1(int i){
inter1_=i;
}
void setInter2(int i){
inter2_=i;
}
int getType(){
return type_;
}
Node* getChild1(){
return child1_;
}
Node* getChild2(){
return child2_;
}
Node* getParent(){
return parent_;
}
void setType(int i){
type_=i;
}
void setChild1(Node* n){
child1_=n;
}
void setChild2(Node* n){
child2_=n;
}
void setParent(Node* n){
parent_=n;
}
void printNode(){
cout << "type: " << getType()<<endl;
}
};
#endif
Comment