I have made a templated class, Node<K,D>.
Say I have some code that goes:
Code:
Node<int,int> ham(1,1);
Node<char,char> potato('n','e');
Node<double,double> gun(3.0,4.44);
and then I want to make potato and gun children of the ham node.
If i declare the node pointers as
Code:
vector<Node<K,D>*> children;
then I can only point to nodes of type Node<K,D>, so ham could not point to potato and gun. Perhaps the solution is to use void pointers - but
Code:
vector<void*> children;
returns this error:
Quote:
error: `void*' is not a pointer-to-object type
|
How do you suggest I expand the functionality of my Node pointers so that they can point to any Node, regardless of the type of keys or data it possesses?
Thanks!