O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.10. Overriding the Inherited Virtual Interface

A derived class can either inherit or override the virtual interface of its base class. To inherit a member, the class need do nothing. Inheritance is the default behavior. To override an inherited abstract or virtual member, however, we must label the definition with the override keyword. Otherwise the compiler treats the instance as an independent definition reusing the name of the inherited member. If you do this—accidentally or not—you'll receive a warning from the compiler. If the warning is spurious, you can turn it off by specifying the new keyword; we see how to do this in Section 3.12.

Both the base-class and derived-class instances of the virtual function must have the same access level, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required