expected initializer before '*' token.

Ok, so i've been looking at this for a while now and can't figure out what is wrong, the error i am getting is:
BtNode.template:75: error: expected initializer before ‘*’ token
BtNode.template:81: error: expected constructor, destructor, or type conversion before ‘*’ token
BtNode.template:87: error: expected initializer before ‘*’ token
BtNode.template:93: error: expected constructor, destructor, or type conversion before ‘*’ token
BtNode.template:99: error: expected initializer before ‘*’ token
BtNode.template:105: error: expected constructor, destructor, or type conversion before ‘*’ token

and below is my BTNode class:
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
template <typename Item>
	BTNode<Item>::BTNode()
	{
		data = NULL;
		left = NULL;
		right = NULL;
		parent = NULL;
		
	}
	
	template <typename Item>
	BTNode<Item>::BTNode(Item* data1, BTNode* left1, BTNode* right1, BTNode* parent1)
	{
		data = data1;
		left = left1;
		right = right1;
		parent = parent1;
	}
	
	//Destructor
	template <typename Item>
	BTNode<Item>::~BTNode()
	{
		delete data;
	}
	
	//Mutators
	template <typename Item>
	void BTNode<Item>::set_data(const Item* new_data)
	{
		data = new_data;
	}
	
	template <typename Item>
	void BTNode<Item>::set_parent(BTNode* new_parent)
	{
		parent = new_parent;
	}
	
	template <typename Item>
	void BTNode<Item>::set_left(BTNode* new_left)
	{
		left = new_left;
	}
	
	template <typename Item>
	void BTNode<Item>::set_right(BTNode* new_right)
	{
		right = new_right;
	}
	
	//Query
	template <typename Item>
	Item* BTNode<Item>::get_data() const
	{
		return data;
	}
	
	template <typename Item>
	const BTNode* BTNode<Item>::get_parent()
	{
		return parent;
	}
	
	template <typename Item>
	BTNode* BTNode<Item>::get_parent() 
	{
		return parent;
	}
	
	template <typename Item>
	const BTNode* BTNode<Item>::get_right() const
	{
		return right;
	}
	
	template <typename Item>
	BTNode* BTNode<Item>::get_right()
	{
		return right;
	}
	
	template <typename Item>
	const BTNode* BTNode<Item>::get_left() const
	{
		return left;
	}
	
	template <typename Item>
	BTNode* BTNode<Item>::get_left()
	{
		return left;
	}
	


any ideas ? thank you
The line numbers in your error messages don't match the line numbers in the code you've pasted. Please could you give us some indication of which lines are causing which errors?

EDIT: The syntax you're using suggests that these method definitions are in a .cpp file separate from the header file that contains the class definition. You can't do that with template classes. Unlike normal classes, the compiler needs to have the entire definition of the templated class/methods/functions available at compile time, so the method definitions have to be in the header file with the class definition.

It would probably make the syntax a lot cleaner if you simply wrote them inline in the class definition.
Last edited on
Sorry i didnt add the top part of my code, the lines with the errors are:
60
66
72
78
84
90
You don't have typename BTNode, so you cannot have pointer to such type either. You could return a BTNode<Item> * ...
Topic archived. No new replies allowed.