Error Templating Two Classes

Hello all,

I am trying to impliment my first binary tree and I am having some issues. The exact error I am getting from visual studios is

 
Error	C2143	syntax error: missing ',' before '<'	


the error is for line 9 and 12 in Tree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#ifndef TREE_H
#define TREE_H

#include"BinaryTree.h"

template <typename T>
class Tree: public BinaryTree<T> {
//class Tree {
private:
	BinaryTree<T> *root;

public:
	Tree();
	Tree(Tree *original);
	Tree(BinaryTree<T> *root1);
	~Tree();
	Tree(T value, Tree *left, Tree *right);

	void copyHelper(BinaryTree<T> *&newOne, BinaryTree<T> *original);
	void print(); 
	

};



#endif
#include"Tree.cpp" 


and my BinaryTree.h code is
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#ifndef BINARYTREE_H
#define BINARYTREE_H
#include<iostream>
#include"Tree.h"

using namespace std;

template<typename T>
class BinaryTree
{
public:
	T value;
	BinaryTree *left;
	BinaryTree *right;
public:
	BinaryTree();
	BinaryTree(T value1, BinaryTree *left1, BinaryTree *right1);
	BinaryTree(BinaryTree *original);
	~BinaryTree();

	T getValue();
	T getLeft();
	T getRight();

	//void copyHelper(BinaryTree *&newOne, BinaryTree *original);

	void Ancestors(T key);

	void tempPrint();


};



#endif
#include"BinaryTree.cpp" 



Any thoughts on how to fix this???

Thanks in advance

Last edited on
Your headers include each other recursively. You should never do that.
BinaryTree.h doesn't anything from Tree.h, so it doesn't need to include it.

I also see that your headers include sources. That's another thing you should never do.
That worked, now I have runtime errors I have to debug :).
Topic archived. No new replies allowed.