Diffrence between Overloading and Overriding

Discussion in 'C++' started by dshivhare, Mar 21, 2007.

  1. dshivhare

    dshivhare New Member

    Joined:
    Mar 20, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Developer
    Location:
    Bangalore
    Hello :)

    Can any body tell me what is the difference between Overloading and Overriding in C++ ??

    Thanks in Advance......
    Deepak
     
  2. vinayak Bhat

    vinayak Bhat New Member

    Joined:
    Mar 21, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    overloading is giving an operator meaning which is needed for us i mean the operator can do the job as we want if we overload
    but overriding is giving some diffrent meaning in to a function which specified in parent process in inheritance
     
  3. dshivhare

    dshivhare New Member

    Joined:
    Mar 20, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Developer
    Location:
    Bangalore
    Can you explain me with an example ??
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Thats what you are saying about operator overloading.

    I dont see any similarity.

    Allows the creation of several functions with the same name which differ from each other in terms of the type of the input and the type of the output of the function.

    Overriding, is a feature that allows a subclass to provide a specific implementation of a method that is already provided by one of its superclasses. The implementation in the subclass overrides (replaces) the implementation in the superclass.
     
  5. tom_ge

    tom_ge New Member

    Joined:
    Mar 20, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    To add on to shabbir...overloading is the process of giving a particular operator another meaning.
    For eg. while using cout << "hello world";
    Here "<<" does not have its actual meaning but is an output operator.This is a form or compile time polymorphism.

    The use of virtual functions is an example for overriding of functions in the subclasses.A form of run time polymorphism.
     
  6. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    A virtual function in the base class does not override the derived function if the derived function exists, unless the call is ambiguous. A pure virtual function requires overriding in the derived class.

    An overloaded operator may give the operator another meaning (as in output versus shift), or it may have the same meaning (add, say) with the operation merely modified. Adding integers is not done in the same way as adding (concatenating) strings.
     
    Last edited: Mar 22, 2007

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice