Explain the difference between function overloading and function overriding.

Last updated 21 June 2026

Overloading is having multiple functions with the same name but different parameter lists, resolved at compile time; overriding is a derived class replacing a base class's virtual function with its own implementation, resolved at runtime.

  • Function overloading:

    • Same scope, same name, different signatures (number/types of parameters). Return type alone does not count.

    • Resolved by the compiler via overload resolution (static/compile-time polymorphism).

  • Function overriding:

    • Requires inheritance and a virtual function in the base; the derived signature must match.

    • Dispatched at runtime through the vtable (dynamic polymorphism) based on the object's actual type.

    • Use override so the compiler verifies you really are overriding and not silently creating a new function.

  • Key contrast: Overloading is about choosing among siblings at compile time; overriding is about choosing the right derived behavior through a base pointer/reference at runtime.

[lang:cpp] struct Base { void f(int); // overload void f(double); // overload virtual void g(); // can be overridden }; struct Derived : Base { void g() override; // override };

  • https://www.geeksforgeeks.org/cpp/function-overloading-vs-function-overriding-in-programming/
  • https://www.interviewbit.com/axis-bank-interview-questions/
  • https://www.interviewbit.com/delhivery-interview-questions/
  • https://www.geeksforgeeks.org/interview-experiences/ibm-interview-questions-and-answers-for-technical-profiles/
  • https://www.scaler.com/topics/difference-between-function-overloading-and-overriding-in-cpp/
  • https://www.mygreatlearning.com/blog/function-overloading-in-cpp/
All C++ interview questions