Thread: C++ classes
View Single Post
Old 12-03-2006, 02:01 PM   #3 (permalink)
KBlair
 
Super Techie

Join Date: Jul 2006

Posts: 298

KBlair is on a distinguished road

Default

They make your life easier by having a template for objects you will frequently use.

For example:

Lets say you're making a game, and you want to make all spaceship objects have certain characteristics, like Speed, Armor, etc.

You can make a class:

Code:
#include <iostream>

using namespace std;

class SpaceShip
{
protected:
	int Armor;
	int Speed;

public:
	void Accelerate()
	{
		cout<<"Your spaceship is zoomin\'!"<<endl;
	}
};

void main()
{
	SpaceShip sp;
	sp.Accelerate();
}
Hopefully that should clarify things.
__________________

See Wii. See Wii run. See Wii blow all the other consoles out of the water!
KBlair is offline