Error C3867 Binary Tree Child Pointers

Hello,

I have a problem with a function that outputs a binary tree as an "inorder string". I've used such a function before so I know the logic of it is right, but now I am accessing the "Nodes" in the tree from a separate class altogether and somehow get an error from that.

Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
string BST::inorder()
{
	return inorder(root);
}

string BST::inorder(Node* n)
{
	stringstream out;

	if (n != NULL)
	{
		out << inorder(n->getLeftChild);   //Error C3867 here
		out << n->getData;                 //Error C3867 here
		out << inorder(n->getRightChild);  //Error C3867 here
	}

	return out.str();
}


Here is the Node class, which is separate from the BST class:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Node : public NodeInterface
{
public:
	Node(int item, Node* right, Node* left);
	~Node() {};

	virtual int getData();
	virtual NodeInterface * getLeftChild();
	virtual NodeInterface * getRightChild();

private:
	int item;
	Node* right;
	Node* left;
};


and the .cpp file associated with it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Node::Node(int item, Node* right, Node* left)
{
	this->item = item;
	this->right = right;
	this->left = left;
}

int Node::getData()
{
	return item;
}

NodeInterface * Node::getLeftChild()
{
	return left;
}

NodeInterface * Node::getRightChild()
{
	return right;
}


I have all the include statements right and stuff, but the debugger tells me I have an error because "Node::getLeftChild': non-standard syntax; use '&' to create a pointer to member".

Please help me.
Last edited on
Member variable or member function?
1
2
out << n->getData;
out << n->getData();

I figured it out, it was the function getLeftChild() and getRightChild() are type NodeInterface* so, the inorder function wasn't allowing them.

Thanks for your help though, you led me to finding the solution!
Topic archived. No new replies allowed.