I'm transferring a project from Java to C++ and I have a problem with something relatively simple in Java.
I have a class X which is made to handle objects of type Y and objects inherited from Y. X often need to call a method from Y, say kewl_method(), and this method is different in each class inherited from Y. In Java I could do something like this:
public class X<y extends Y>
I would call kewl_method() in X without any headache and it would do what I want. If I understand correctly (I'm new to C++), there is no such thing as bounded genericity in C++, so if I use a template with X it would be possible to fill it with absolutely anything and I won't be able to call the variants of kewl_method().
What is the best way to do this in C++ ? Using casts ?
Restriction: I cannot use boost or TR1.