Question:

What happens if a derived class defines a function with the same name as a base class function, but with a different parameter list?

Show Hint

Think about C++ name lookup. If a name is found in the derived scope, does the compiler keep looking in the base scope?
Updated On: Jul 2, 2026
  • It overrides the base class function
  • It forces explicit scope resolution to call the base class function
  • It hides the base class function
  • It causes a compilation error
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: In C++, a name declared in a derived class hides every member with the same name in the base class. This is called name hiding.

Step 2: Once the derived class declares a function with that name, the whole set of base class overloads of that name is removed from the derived class scope. The compiler does not merge the base and derived overload sets, even when the parameter lists differ.

Step 3: So a call like
 derivedObj.func(args);
only looks at the derived class version. If the arguments do not match the derived signature, you get an error, not a fall back to the base version.

Step 4: This is not overriding. Overriding needs the same signature and a virtual function. Here the signatures differ, so it is plain hiding. To reach the base version you must write \( base::func \) explicitly, but the default effect is that the base function is hidden.

Answer: option C.
Was this answer helpful?
0
0