Re: What about real polymorphism ?? [message #41990 is a reply to message #41984] |
Thu, 09 December 2004 07:00   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Antonio Santiago writes:
> my problem is with IDL's polymorphism, i think it's a half-polymorphims
> instead real polymorphism.
>
> Supose we have a class Person and two subclasses Man and Woman. Class
> Person has a class called GetInfo() that is overriden in both Man and
> Woman. The question is:
>
> How can i create an array of Person's (that is Man or Woman objects) and
> call the method GetInfo() in the way that depends on the subtype of
> every object it invoques the Man GetInfo() or the Woman GetInfo()??
>
> One possible solution is using OBJ_ISA funtion for every object in the
> array but i want to know if it is possible only with polymorfism in IDL
> like in Java or other OO languages.
I don't understand this question. (Probably I don't
understand what "polymorphism" means, in IDL or anywhere
else, but leave that for a moment.) If you have an array
of mixed man and woman objects, and you call a GetInfo()
method on *any* object, how is it possible NOT to call
the correct method, assuming both man and woman objects
have overwritten the person method? I just can't see
where the problem arises.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|