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>]


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

Get C# Primer Plus now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.