这是我的二叉树的头文件。我有一个名为 TreeNode 的类,当然 BinaryTree 类有一个指向其根的指针。
我得到以下三个错误
error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
和 BinaryTree 头文件的代码
#pragma once
#include <fstream>
#include <iostream>
#include "Node.h"
using namespace std;
class BinaryTreeStorage
{
private:
TreeNode* root;
public:
//Constructor
BinaryTreeStorage(void);
//Gang Of Three
~BinaryTreeStorage(void);
BinaryTreeStorage(const BinaryTreeStorage & newBinaryTreeStorage);
BinaryTreeStorage& operator=(const BinaryTreeStorage & rhs);
//Reading and writing
ofstream& write(ofstream& fout);
ifstream& read(ifstream& fin);
};
//Streaming
ofstream& operator<<(ofstream& fout, const BinaryTreeStorage& rhs);
ifstream& operator>>(ifstream& fin, const BinaryTreeStorage& rhs);
错误似乎在第 11 行
TreeNode* root;
我花了几天时间试图摆脱这个错误并且完全被摧毁。
这是关于错误命名空间的错误吗?或者也许 TreeNode 类没有声明正确?
并以防万一 TreeNode 头文件的代码
#pragma once
#include <string>
#include "BinaryTreeStorage.h"
using namespace std;
class TreeNode
{
private:
string name;
TreeNode* left;
TreeNode* right;
public:
//Constructor
TreeNode(void);
TreeNode(string data);
//Gang of Three
~TreeNode(void);
TreeNode(const TreeNode* copyTreeNode);
//Reading and writing
ofstream& write(ofstream& fout);
//Add TreeNode
void addTreeNode(string data);
//Copy tree
void copy(TreeNode* root);
};
先感谢您。