classes are ways to describe things. Objects are individual instances of a class. Let's say you want to describe a car. In english you can say a car has 4 tires (usually), a steering wheel, and engine, some doors. It can run at a certain miles per hour and it can go a certain direction. To change this into C++ you can do this:
Code:
enum Direction {north, south, east, west};
class Car
{
public:
int numTires;
int numSteeringWheel;
int sizeEngine;
int numDoors;
int speed;
Direction direction;
void changeSpeed(int);
void changeDirection(Direction);
};
That's a generic description of what a car contains and what it can do using a class C++. Note that descriptions of what it contains are usually described by variables, and what it can do is described by functions. But what about any given car. It might have 2 doors instead of 4, it might havea big engine or a small one. It might be heading East, not West. How do you know. Well, you are in charge. You decide by setting it up the way you want using a instance of the class Car (otherwise known as an object).
Car puttputt;
puttputt.numTires = 4;
puttputt.numSteeringWheel = 1;
puttputt.numDoors = 4;
puttputt.sizeEngine = 100;
puttputt.speed = 0;
puttputt.direction = East;
Then how do you change the speed or direction? You use the functions in the class:
puttputt.changeSpeed(23);
puttputt.changeDirection(North);
where the definitions are defined as:
Code:
void Car::changeSpeed(int x)
{
speed = x;
}
void Car::changeDirection (Direction _direction)
{
direction = _direction;
}
So far this is a pretty rough description of a classes. You can, should, and will get more sophisticated in their use. The text previously recommended is good, but I think it is more useful if you know some C first. For someone not knowing C I recommend the online version of Teach Yourself C++ in 21 days by Liberty if you want an online text. I still feel more comfortable with a hard copy, though, and there there are a number of highly regarded choices. Get one if you are serious about persuing the language.