Classes

A class is the fundamental element in an object oriented system.

All classes of an object oriented system are arranged in a class hierarchy with one root class at its top.

 

Campione and Walrath define a class in the following way:

"A class is a blueprint or prototype that defines the variables and the methods common to all objects of a certain kind."

[CW96, "What are classes?"]

What does that mean?

» blueprint: A class can't do anything on its own.

» defines: A class provides something that can be used later.

» objects: A class can only be used, if it had been "brought to life" by instantiating it.

 

Example: Class "Car"

The class Car
The class Car

As can be seen, the class, representing a car, has variables (brand, speed, gear, ...) and methods (accelerate, brake, ...). This class serves as a generic description of any existing car, because each real-world thing that is a car, has, for example, a speed, a number of wheels, ... And when driving a car, you can accelerate it or change the current gear.

 

But you don't drive a generic car with a number of wheels at a speed.

You usually drive a specific car with, for example, four wheels at 50 mph.

 

This specific car is an instance of the class "Car" and is then called an object.

Neural Net Components in an Object Oriented Class Structure