Which of the following differentiates between overloaded functions and…

20142025

Which of the following differentiates between overloaded functions and overridden functions ?

  1. A.

    Overloading is a dynamic or runtime binding and overridden is a static or compile time binding.

  2. B.

    Overloading is a static or compile time binding and overriding is dynamic or runtime binding.

  3. C.

    Redefining a function in a friend class is called overloading, while redefining a function in a derived class is called as overridden function.

  4. D.

    Redefining a function in a derived class is called function overloading, while redefining a function in a friend class is called function overriding.

Attempted by 194 students.

Show answer & explanation

Correct answer: B

Key distinction: Overloading is resolved at compile time; overriding is resolved at runtime.

  • Function overloading

    : Multiple functions share the same name but have different parameter lists (different number, types, or order of parameters). The compiler selects the correct function based on the argument types, so binding is done at compile time.

    Example: void f(int); void f(double); calling f(3) binds to f(int) at compile time.

  • Function overriding

    : A derived class provides a new implementation for a base class method with the same signature. For languages that support runtime polymorphism (for example, using virtual functions in C++), the actual method called depends on the object's runtime type, so binding is done at runtime.

    Example: A base class declares virtual void show(); and the derived class defines void show(); When a base-class pointer refers to a derived object, the derived show runs at runtime.

Additional notes:

  • Overloading requires different parameter lists; overriding requires the same signature (or compatible signature) in the derived class.

  • Friend classes are unrelated to the definitions of overloading and overriding; redefining a function in a friend class is not a standard term.

Explore the full course: Mppsc Assistant Professor