In C++, what is the difference between method overloading and method overriding?

Author Topic: In C++, what is the difference between method overloading and method overriding?  (Read 1251 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 139
  • Karma: 0
    • No Addiction
Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class.

Offline TomClarke

  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You 15
  • Posts: 896
  • Karma: 0
Method overloading happens i the same class shares the same method name but each method should have different number of parameters having different types and order. But in the method overriding derived class have the same method with same name and exactly the same number and type of parameters and same return type as a parent class. Also method overloading happens at compile time while overriding happens at runtime.

Offline abhik143

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 1
  • Karma: 0
1.In overloading,there is a relation ship between methods available in the same class where as in overridding,there is relationship between a super class method and subclass method.
2.Overloading doesn't block inheritence from the superclass where as overridding blocks inheritence.
3.In overloading,seperate methods share the same name where as in overridding,subclass methods replaces the superclass.
4.Overloading must have different method signatures where as overriding must have same signature.


1. Overriding
public class MyBaseClass
    public virtual void MyMethod()
        Console.Write("My BaseClass Method");

public class MyDerivedClass : MyBaseClass
    public override void MyMethod()
        Console.Write("My DerivedClass Method");


2. Overloading
int add(int a, int b)
int add(float a , float b)

Reference:- newbielink: [nonactive]

Offline alisaa

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 4
  • Karma: 0
    • Nationkart
Method Overloading : When more than one method shares the same name in the class but having a different signature.
Method Overriding : When a method of base class is re-defined in the derived class having the same signature.

Method Overloading : It is a compile-time polymorphism.
Method Overriding : It is a run time polymorphism.
newbielink: [nonactive]


Related Topics

  Subject / Started by Replies Last post
6 Replies
Last post 09-23-2011, 13:18:35
by Johan68
38 Replies
Last post 09-30-2013, 05:42:55
by sonusmith
0 Replies
Last post 03-19-2012, 06:39:02
by Vinil
28 Replies
Last post 04-25-2016, 13:09:50
by vishistsingh
6 Replies
Last post 10-24-2013, 07:10:51
by alexloxton