I am using template classes in c++. I create an object of the class as below:
Node<int> *rootNode = (Node<int> *) malloc(sizeof(Node<int>));
Now I insert few entries in the Node. After I see that the node is full, i want the code to create a new node with same typename as that of the root node and store the required data. Below is my method for insertion:
template <typename T>
RC Node<T>::Insert(void *key)
{
if(space() > 0) { // check if current node has ample space
// add data in the current node
}
else
{
siblingNode = new Node<T>();
if (this->Split(siblingNode, key)) {
if (siblingNode != NULL) {
siblingNode.display();
}
}
}
}
}
I try to display the new node created using
siblingNode.display()
method but it gives me compilation error
request for member ‘display’ in ‘siblingNode’, which is of non-class type ‘Node<int>*’
How to ensure that the siblingNode is of the same typename as that of the node from which the insert function is invoked ?