【发布时间】:2017-02-18 02:46:12
【问题描述】:
我正在使用 C++ 实现 bptree。我被困在节点创建的初始步骤中。不断收到“C2011 'Node':'class' 类型重新定义”错误。我在网上找到了一些从 cpp 文件中删除类关键字的建议。但是当我删除 class 关键字时,我会收到很多其他错误。这是我的 Node.cpp 代码:
#include "Node.h"
#include <cstdio>
#include <iostream>
#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
//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;
}
}
};
Node.h文件如下:
#pragma once
#ifndef NODE_HEADER
#define NODE_HEADER
class Node {
public:
Node(int order) {};
};
#endif
我该如何解决这个问题?
【问题讨论】:
标签: c++