Why am I getting linker errors?

So I have 6 linker errors which tell me some of my functions which are referenced in my .cpp file dont exist. These functions are in my .h file which I have included at the top of my .cpp file. This is how my project is set up:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
//BST.h
class BinarySearchTree{
public:
//constructor and destructor
virtual void functiona(){};
virtual void functionb(){};
//overloaded operator
protected:
void functionC(){};
void functionD(){};
void functionE(){};
private:
int someValue;
};

1
2
3
4
5
6
7
8
9
10
11
12
//BST.cpp
#include "BST.h"

BinarySearchTree::BinarySearchTree(){
someValue = 1;
}
void BinarySearchTree::functiona{
   functionE();
}
void BinarySearchTree::functionb{
   functionD();
}


My compiler yells at me saying:

Error 33 error LNK2019: unresolved external symbol "protected: void __thiscall BinarySearchTree::functionE(class TreeNode *,void (__cdecl*)(class KeyedItem &))" (?postorder@BinarySearchTree@@IAEXPAVTreeNode@@P6AXAAVKeyedItem@@@Z@Z) referenced in function "public: virtual void __thiscall BinarySearchTree::functiona(void (__cdecl*)(class KeyedItem &))" (?postorderTraverse@BinarySearchTree@@UAEXP6AXAAVKeyedItem@@@Z@Z) C:\Users\izik\Documents\Visual Studio 2010\Projects\BSTInsertDelete\BST.obj BSTInsertDelete


What's going on here? Anyone have some speculations as to what I'm doing wrong?
Last edited on
The linker says very clear that it did not find such functions.
Can you point out for example where did you define function

void __thiscall BinarySearchTree::functionE(class TreeNode *,void (__cdecl*)(class KeyedItem &))"

???
Last edited on
Thanks for the reply. FunctionE is defined within the same class that function a is. I edited my original post to illustrate this.
Last edited on
The linker searches the function that takes two parameters the first of them is TreeNode *. Check your program to see where you call the function.
You didn't define functionE in the class; you declared it there. You need to define it in your cpp file like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//BST.cpp
#include "BST.h"

BinarySearchTree::BinarySearchTree(){
someValue = 1;
}
void BinarySearchTree::functiona{
   functionE();
}
void BinarySearchTree::functionb{
   functionD();
}

void BinarySearchTree::functionE{
   ++someValue;
}
Last edited on
Topic archived. No new replies allowed.