I want to create an abstract class C and subclasses A and B (they both inherit from C) and then I want to have a function called "foo" with the following definitions
where the object that is returned(pointed to) is of class A only if foo is called with A*, A* arguments and otherwise it's a B object.Code:C* foo(A* x, A* y); C* foo(B* x,B* y); C* foo(A* x,B* y); C* foo(B* x,A* x);
So foo must be overloaded, but how can the different objects be identified at runtime?
How can I make this work? How do I write foo?