I have a private variable of type struct node (note that the struct node has left,right and parent pointers as well as the property: T value
, where T is a template type) in a header file:
node<T>* root
I then have the following method in a .cpp file:
template<> void RedBlack<int>::setRoot(int elem) {
root->value=elem;
}
However when I try to create an instance of the class in the main method and then try to set the value of the root from there, I get a runtime error: bad access.
Any idea as to what is wrong? P.S. Still new to the 'templates' concept.