Learn classes, objects, and heap memory
Object-Oriented Programming is a way to organize code using objects and classes. Classes are templates that define what data (properties) and actions (methods) an object should have.
A blueprint or template for creating objects.
A specific copy created from a class.
Variables that belong to an object.
Functions that belong to a class.
`class ClassName {
// Properties
type propertyName;
// Methods
returnType methodName(parameters) {
// method body
}
}
// Create an object
ClassName obj = ClassName();
obj.propertyName = value;
obj.methodName();
`When you create an object:
1. A reference is created on the stack
2. The actual object is created on the heap
3. The reference points to the object on the heap