13.10. More About Inheritance and C#
From our discussion of inheritance in Chapter 5, we learned that
Inheritance is used to derive a new class definition from an existing class when the new class is perceived to be a special case of the existing class.
The derived class automatically inherits the data structure and behaviors of the base class.
C# uses a colon followed by a class name in a class declaration to signal that one class is derived from another:
public class Person { private string name; public string Name { get { return name; } set { name = value; } } } // We derive the Student class from Person. public class Student : Person { // If we define nothing in the body of this class, it will still // have one field, name, and one property, ...
Get Beginning C# 2008 Objects: From Concept to Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.