Hi Guys,
In my recent thread on a polymorphism problem I thought I had it all figured out but now I have I new problem.
Now I want to pass in 2 objects of either type bird or pigeon
int main()
{
Bird B1;
Pigeon P1;
DoSomething ( &B1, &B2 );
DoSomething ( &P1, &P2 );
}
void DoSomething(*ptr1, *ptr2){
ptr1->methodA(*ptr2)
//Where methodA will return an object of Type Bird or
//Pigeon depending on what *ptr1 and *ptr2 are pointing
//to. As methodA is a virtual function and has been
//redefined for Pigeon.
}
What I want to do is print out the data held in the object returned by methodA but I cannot say myResult = ptr1->methodA(*ptr2) and print out myResult as I do not yet know the type of myResult.
Is there anyway I can achieve this?
Any ideas welcome,
Thanks.