This is header file for my binary tree.
I have a class called TreeNode and of course BinaryTree class have a pointer to its root.
And I got following Three errors
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
And Code for BinaryTree header file
#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);
error appears to be at line 11
TreeNode* root;
I have spent few days trying to get rid of this error and completely devastated.
Is this error about wrong namespace ? Or maybe TreeNode class not declared right?
And just in case code for TreeNode header file
#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);
};
Thank you in advance.
Instead of
simply forward declare the class:
Also, why are you including
BinaryTreeStorage.hinNode.h? There’s no need for it, so remove it.