You Like My Tutorials? Click The Banner To Keep 'Em Coming!

glGameDeveloper(): The Game Developer's Source for OpenGL Coding
Main Menu
Latest News
Archived News
Tutorials
Links
E-Mail Me

Other
Message Board
My Guestbook

Tutorials -- Working with Objects
 


Working with Objects Using Classes Page 1 of 4
< Previous Jump to Page: 1 | 2 | 3 | 4 Next >

Working with Objects Using Classes

Encapsulation is probably a word you've heard a lot about if you've read anything on C++ programming. So what the heck is it? It means grouping variables and functions into a "class", so that they can be re-used as different "instances" of that class.

Think of a class as though it were a blueprint for a house. A blueprint can be reused to make several houses, all with similar features but maybe different properties (ex. colored walls or different style of windows). But a blueprint isn't a house, is it? Nope, it's simply a reusable plan for a house.

To take this further, lets use this analogy to explain subclassing. Say we want two types of blueprints. One blueprint we'll keep the same as it originally was, and one we want to add a backyard swimming pool to. It would be downright stupid to make a whole new blueprint just to add the pool. We'd want to use the same blueprint, which has all the same properties of the other houses made with it, but this time we'll add the pool to it.

This is how subclassing works. Instead of making a whole new blueprint, we reuse them to add on specific things. Instead of rewriting the same functions for each class, we reuse them to add on specific properties. Hopefully this has cleared up any confusion with classes and subclassing.

Move on to learn how to define classes and make instances of classes.

Working with Objects Using Classes Page 1 of 4
< Previous Jump to Page: 1 | 2 | 3 | 4 Next >

This site best viewed with MS Internet Explorer 5.0 at 16-bit color and at least 800x600.

All Contents of this site are Copyright 1999, 2000 Joe Zimmerman. No part of this site (code, HTML, etc.) may be reproduced without my permission.

Click Here!