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.
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.
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.
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.