O'Reilly logo

C# Primer Plus by Klaus Michelsen

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

Inheritance Fundamentals

The basic syntax for deriving a class from a base class is shown in Syntax Box 16.1. We write the class header of the derived class as usual by specifying any optional modifiers followed by the class keyword and the classname. The different and important bit in this context is the semicolon (:) followed by the name of the class we want as a base class for the derived class. The meaning of the semicolon could consequently be “is derived from.”

Syntax Box 16.1 Class Definition with Optional Derivation

						Class_definition_with optional_derivation::=
						[<Access_modifier>] class <Derived_class_name> [ : <Base_class_name>]
{
    <Class_members_of_derived_class>
}

Note:

The colon followed by the base classname (: <Base_class_name> ...

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