<< Chapter < Page Chapter >> Page >
Baldwin explains the use of the Object class as a completely generic type for storing references to objects of subclass types, and explains how that results in a very useful form of runtime polymorphism.

Revised: Sat May 07 11:13:14 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.

Object-oriented programs exhibit three main characteristics:

  • Encapsulation
  • Inheritance
  • Polymorphism

I have explained encapsulation, inheritance, compile-time polymorphism, and runtime polymorphism using method overriding and class inheritance in earliermodules. This module will explain the importance of the Object class in polymorphic behavior. I will defer an explanation of polymorphism usinginterface inheritance until a future 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 . Text output for ToString method and class A.
  • Figure 2 . Text output for overridden ToString method and class B.
  • Figure 3 . Text output for overridden ToString method and class C.

Listings

General background information

The generic type Object

In this module, I will explain the use of the Object class as a completely generic type for storing references to objects of subclasstypes, and will explain how that results in a very useful form of runtime polymorphism.

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