Reputation: 351
I feel like I'm taking crazy pills. The syntax is what I've used before (taken from example classes from my class) and haven't had any issues. The only difference is I'm using Visual Studio 2013 now. I keep getting this error when I attempt to build my solution (it happens for all the methods so clearly I must have some syntax wrong?)...
error C2244: 'node<T>::getItem' : unable to match function definition to an existing declaration
1> c:\users\milan\documents\visual studio 2013\projects\threadedbst\threadedbst\node.h(19) : see declaration of 'node<T>::getItem'
1> definition
1> 'T node::getItem(void)'
1> existing declarations
1> 'T node<T>::getItem(void)'
Here is the simple node class I was making using a template.
using namespace std;
//---------------------------------------------------------------------------
// node<T> class:
// --
//
// Assumptions:
// -- <T> maintains it's own comparable functionality
//---------------------------------------------------------------------------
template <typename T>
class node {
public:
node(T* value); //constructor
node(const node<T>&); //copy constructor
void setFrequency(int); //sets the frequency
int getFrequency(); //returns the frequency
T* getItem(); //returns the item
private:
T* item;
int frequency;
node<T>* leftChild;
node<T>* rightChild;
bool leftChildThread;
bool rightChildThread;
};
//-------------------------- Constructor ------------------------------------
template <typename T>
node<T>::node(T* value) {
item = value;
frequency = 1;
}
//-------------------------- Copy ------------------------------------
template <typename T>
node<T>::node(const node<T>& copyThis) {
item = copyThis.value;
frequency = copyThis.frequency;
}
//-------------------------- setFrequency ------------------------------------
template <typename T>
void node<T>::setFrequency(int num) {
frequency = num;
}
//-------------------------- getFrequency ------------------------------------
template <typename T>
int node<T>::getFrequency() {
return frequency;
}
//-------------------------- getItem ------------------------------------
template <typename T>
T* node<T>::getItem() {
return item;
}
Upvotes: 0
Views: 222