CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Location
    Chennai
    Posts
    8

    Operator Overloading

    Hello ,
    we can classify the Polmorphism are two types
    1.Dynamic. Ex - Virtual Functions.
    2.Static. Ex - Function Overloading.

    But I have simple doubt. Operator Overloading is also belongs to
    static Polymorphism.
    Is it correct ?.

    Please Explain me.

    Thanks.
    Prem.

  2. #2
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    Incorrect.

    Polymorphism is otherwise known as dynamic binding. It is always done through virtual function. During runtime it requires the use of vtable to determine which function to invoke. In addition, the subclass that implements the virtual function must also have the same function signature.

    Function overloading doesn't do polymorphism. Since the function signature of overloaded functions are different, they are consider as different functions. During compilation, overloaded functions are mangled so that they are distinguished as different function.

    If I am not wrong, the closest to static polymorphism is through the use of templates.

  3. #3
    Join Date
    Feb 2002
    Posts
    69
    Definition (Polymorphism (1)) The concept of dynamic binding allows a variable to take different types dependent on the content at a particular time. This ability of a variable is called polymorphism.

    Definition (Polymorphism (2)) If a function (or method) is defined by the combination of
    ·its name and
    ·the list of types of its parameters we speak of polymorphism.

    Definition (Polymorphism (3)) Objects of superclasses can be filled with objects of their subclasses. Operators and methods of subclasses can be defined to be evaluated in two contexts:

    1. Based on object type, leading to an evaluation within the scope of the superclass.
    2. Based on object content, leading to an evaluation within the
    scope of the contained subclass.

    The second type is called polymorphism.

  4. #4
    Join Date
    Oct 2003
    Location
    Philadelphia, PA
    Posts
    167
    Some suggestions for nailing down these thoughts in your mind:

    Dynamic binding is a data feature of the language that allows fuzzy typing.

    Polymorphism is a feature of all object-oriented langauges and generally follows the principles discussed in this forum.

    The definition of object-orientation is the ability to dynamically inherit and construct classeses based on a chosen inheritance; it doesn't necesarily pertain to super and sub-classes.

    Finally, polymorphism can be a very elegant solution, but if you're new at it or are a little fuzzy, make sure you have someone really experienced over your shoulder, becuase the damage that can be done when improperly implemented can be very devastating.
    Mike Dershowitz
    miked@lexientcorp.com
    www.lexientcorp.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured