Lesson 1: What is a class? Your first object
So far you wrote separate variables and functions. In this lesson we meet class — a way to package data and behavior together. A class is a template, and an object is what gets created from it.
A class is a cake recipe. The object is the actual cake. From one recipe you can bake as many cakes as you want — and each cake is separate.
- class
- A template that defines what an object will look like and what it can do.
- object
- A single concrete thing created from the class — with its own data.
- attribute
- A piece of data that belongs to a specific object, e.g. rex.name.