這是我的二叉樹的頭文件。 我有一個名爲TreeNode的類,當然BinaryTree類有一個指向它的根的指針。錯誤C2143:語法錯誤:缺少';'聲明指針前'*'之前
而且我得到了以下三個錯誤
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
和代碼二叉樹的頭文件
#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類沒有宣佈正確?
而就在樹節點頭文件
#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);
};
情況下,代碼預先感謝您。
謝謝大家回答問題,這確實是一個愚蠢的問題。那就是如果你在C++之前編程C#會發生什麼。 –