Classes and Objects - heshawacooray/OOP-Heshawa GitHub Wiki

Classes and Objects Definition: A class is a blueprint or template for creating objects. It defines properties (variables) and behaviors (functions/methods) that the objects created from it will have.

An object is an instance of a class. When a class is instantiated, it creates an object that holds actual values for the properties defined in the class.

class Car {
private:
    string brand;
    int year;

public:
    Car(string b, int y) {
        brand = b;
        year = y;
    }

    void display() {
        cout << "Brand: " << brand << ", Year: " << year << endl;
    }
};