weakness and strenghs of Polymorphism?

This is a discussion on weakness and strenghs of Polymorphism? within the C++ Programming forums, part of the General Programming Boards category; ne one knows? a few lines on it?...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    4

    weakness and strenghs of Polymorphism?

    ne one knows? a few lines on it?

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Sounds a bit like a homework assignment .

    A polymorphic function call is slower than an ordinary function call, but it allows the code that is using the polymorphic call to change and adapt more easily.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    polymorphism is more an idea than anything concrete. it's the idea that the interface of a variety of functions and classes should be able to work together without a change in code. to be totally honest, it seems pretty important from what the books i've read told me. but i can't really see a big advantage to it. this kind of question sounds like a job for prelude.

  4. #4
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Polymorphism replaces the 'structure embedded union' and 'case analysis' such as if/else or swith/case statements.

    If you have a list of items and you want to loop through them and compute information it is easier to use polymorphism rather than adding case statements for each type of object. Polymorphism allows a group of hetrogenious objects to appear homogenious. It is effectively paired with iheritance.

  5. #5
    Registered User fletch's Avatar
    Join Date
    Jul 2002
    Posts
    176
    I thought that polymorphism is what allows you to overload functions, have multiple inheritence, declare virtual functions, and assign base class pointers to derived classes. Basically do all those things that make classes and OOP handy.
    "Logic is the art of going wrong with confidence."
    Morris Kline

  6. #6
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Originally posted by fletch
    I thought that polymorphism is what allows you to overload functions, have multiple inheritence, declare virtual functions, and assign base class pointers to derived classes. Basically do all those things that make classes and OOP handy.
    Most of the time they are used together however they are different. Overloading functions is used in specialization inheritance in order to preserve method names of the base classes (interfaces) but not behavior (implementation). Multiple inheritance involves deriving from two or more different base classes, and virtual functions are used with polymorphism in order for dynamic binding to take place (the objects are not known at compile time). They are not statically created.

    At least this is what I gather but I'm not exactly a C++er.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21