C++ templated Node class: pointers to different instantated class types
I have made a templated class, Node<K,D>.
Say I have some code that goes: Code:
Node<int,int> ham(1,1); If i declare the node pointers as Code:
vector<Node<K,D>*> children; Code:
vector<void*> children; Quote:
Thanks! |
Code:
vector<void*> children; |
I think what you are looking for is boost::any, but something smells wrong about what you're trying to do.
|
I can't say that I recall having done anything like that before, but using void * should work although it would mean that you will need to cast back to the appropriate class when you remove it from the vector. I'd suggest that you have a parent class called (for example) Object which each of the other classes inherit from and then you just need to have a vector of Objects.
|
All times are GMT -5. The time now is 04:34 AM. |