<< Chapter < Page Chapter >> Page >
Learn how one class can extend another class and inherit all of the properties, events, and methods defined in that class and all of its superclasses; that even though a class may be extended into another class, it remains viable and can be instantiated in its own right; that inheritance is hierarchical with the overall hierarchy being rooted in a class named Object; that C# does not support multiple inheritance; about the ISA and HASA relationships.

Revised: Thu May 05 14:27:52 CDT 2016

This page is part of a Book titled XNA Game Studio .

Table of Contents

Preface

This module is one in a collection of modules designed primarily for teaching GAME 1343 Game and Simulation Programming I at Austin Community College in Austin, TX. These modules are intended tosupplement and not to replace the textbook.

An earlier module titled Getting Started provided information on how to get started programming with Microsoft's XNA Game Studio.

The three main characteristics of an object-oriented program

Object-oriented programs exhibit three main characteristics:

  • Encapsulation
  • Inheritance
  • Polymorphism

I will explain and illustrate inheritance along with some related topics in this module.

Viewing tip

I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the Figuresand Listings while you are reading about them.

Figures

  • Figure 1 . Output from the program named Airship01.

Listings

General background information

The first of the three major characteristics of an object-oriented program is encapsulation . I explained encapsulation in an earlier module. The second of the three is inheritance , followed by polymorphism . I will explain inheritance in this module and will explain polymorphism in a future module.

A new class can extend an existing class

A class can be defined to inherit the properties, events, and methods of another class. From a syntax viewpoint, this is accomplished using the : (colon) operator (see Listing 2 ).

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Xna game studio. OpenStax CNX. Feb 28, 2014 Download for free at https://legacy.cnx.org/content/col11634/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Xna game studio' conversation and receive update notifications?

Ask