私はb ++をC++で開発しようと考えています。私はC + +プログラミングで非常に新しいです、そして、私は彼らが何であるか分からないこのエラーを得ました。 Node.hLNK2005とLNK1169でC++エラー
#ifndef NODE_HEADER
#define NODE_HEADER
#include <string>
#include <map>
using namespace std;
class Node {
bool leaf;
Node** kids;
map<int, string> value;
int keyCount;//number of current keys in the node
public:
Node(int order);
void printNodeContent(Node* node);
friend class BpTree;
};
#endif
Node.cpp
#include <cstdio>
#include <iostream>
#include "Node.h"
//constructor;
Node::Node(int order) {
this->value = {};
this->kids = new Node *[order + 1];
this->leaf = true;
this->keyCount = 0;
for (int i = 0; i < (order + 1); i++) {
this->kids[i] = NULL;
}
}
void Node::printNodeContent(Node* node) {
map<int,string> values = node->value;
for (auto pval : values) {
cout << pval.first << "," ;
}
cout << endl;
}
void main() {
}
BpTree.h
#ifndef BPTREE_HEADER
#define BPTREE_HEADER
#include "Node.cpp"
class BpTree
{
Node *root;
Node *np;
Node *x;
public:
int order;
BpTree();
~BpTree();
BpTree(int ord);
int getOrder();
Node* getRoot();
bool insert(int key, string value);
};
#endif
BpTree.cpp
:![enter image description here](https://i.stack.imgur.com/6M72T.png)
は、私は4つのファイルを持っています
私はここで何が欠けているのですか?私は.hファイルまたは.cppファイルを一度だけインクルードしようとしました。しかし、まだこのエラーが発生します。いずれかの人にこれを修正する方法に関する提案があれば、本当に感謝しています。
Node.cppを含むNode.hをBpTree.hファイルに含めないでください。 – Rob