134k views
3 votes
In the context of object-oriented programming, what occurs when a derived class has the same name and signature as a base class virtual function?

a) Overloading
b) Overriding
c) Inheritance
d) Polymorphism

User TimY
by
8.3k points

1 Answer

1 vote

Final answer:

When a derived class has the same name and signature as a base class virtual function, it is called overriding. It allows the derived class to provide its own implementation of the virtual function while maintaining the same interface as the base class.

Step-by-step explanation:

When a derived class has the same name and signature as a base class virtual function, it is called overriding. Overriding allows the derived class to provide its own implementation of the virtual function and replace the base class implementation.

By overriding a virtual function, the derived class can define its own behavior for that function while still maintaining the same interface as the base class.

User Son Huynh
by
7.9k points