Polymorphic functions with parameters from a class hierarchy

Posted by myahya on Stack Overflow See other posts from Stack Overflow or by myahya
Published on 2010-04-13T08:44:25Z Indexed on 2010/04/13 8:52 UTC
Read the original article Hit count: 320

Filed under:
|

Let's say I have the following class hierarchy in C++:

class Base;
class Derived1 : public Base;
class Derived2 : public Base;


class ParamType;
class DerivedParamType1 : public ParamType;
class DerivedParamType2 : public ParamType;

And I want a polymorphic function, func(ParamType), defined in Base to take a parameter of type DerivedParamType1 for Derived1 and a parameter of type DerivedParamType2 for Derived2.

How would this be done without pointers, if possible?

© Stack Overflow or respective owner

Related posts about c++

Related posts about polymorphism