AVL Tree Creation Problem

Hello all,

I am trying to make my first implementation of a AVL Tree. However when I compile and run the code, it does not output the value of the root. Any ideas?
I am using Microsoft Visual C++ 2010 express. Thanks in advance.

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

//File: avltree.h


#ifndef AVLTREE_H
#define AVLTREE_H

template <typename T>

class AvlTree
{
	public:
		AvlTree();

	private:
		int *root;
		int *parent;
		int *leftChild;
		int *rightChild;
		T data;

};

#endif


//File: avltree.cpp

#include <iostream>
#include "avltree.h"

using namespace std;

template <typename T>
AvlTree<T>::AvlTree()
{
	root = NULL;
	cout << "root: " << root << endl;
}


//File: main.cpp

#include <iostream>
#include "avltree.h"

using namespace std;

int main()
{
	AvlTree<int>AvlTree();

	cin.get();
	return 0;
}
This is a common problem related to most vexing parse. On line 51 (the first line of your main function) you do not create an object - instead, because of the parentheses, you declare a function named AvlTree which takes no parameters and returns an instance of a AvlTree<int> by copy.

Remove the parentheses.
Topic archived. No new replies allowed.