Skip to content
BENIBIX Learn

Class vs Object

A class and an object are not the same thing. The class is the plan, like a cookie cutter. An object is one real thing made from it, with its own values.

Development🧭 Programming Paradigms

Class

A plan for making objects. It lists their data and their actions.

A class is a plan for making objects of one kind, like dogs or players. It says what data each object will hold and what actions it can do. The class itself is just the plan; each object made from it is real and has its own values. In most languages a class name starts with a capital letter. You use the class name to make a new object.

Example
Emma writes a Dog class with a name and a speak method. She makes a dog called Rex from it, and Rex says woof.
Why it matters
Classes let you write the shape of a thing once and reuse it everywhere.
Full entry
Development🧭 Programming Paradigms

Object (Programming)

One real thing made from a class, with its own values. Also called an instance.

An object is one real thing made from a class, holding its own values. Two dog objects made from the same Dog class can have different names and ages. An object is also called an instance of its class. You reach its data and actions with a dot, like rex.name or rex.speak(). Changing one object does not change the others.

Example
Jack makes two Dog objects, Rex and Bo. Giving Rex a new name leaves Bo exactly as he was.
Why it matters
Objects are what a program actually works with. The class only describes them.
Full entry

In one line

Class
A plan for making objects. It lists their data and their actions.
Object (Programming)
One real thing made from a class, with its own values. Also called an instance.