2020-05-03 15:12:03 +02:00

1.0 KiB

Creating Classes

This lesson is going to use the same code from last time to explain the class structure itself.

Since the example languages can have quite different styles of class declaration, I will just give a basic explanation here and then discuss every language in detail in their own description file.

Classes are blueprints for the objects you create. You define how the object will look like and more importantly for the computer how much space it will use in memory.

The main parts of a class are fields and methods. One for storing data and one for processing that data. Fields are placed at the top of the class and look like general variable declarations. Methods can take in arguments and also use the fields declared in the class. They can modify data in the object or just return some data to the caller.

Code examples and language specific explanations