Classes and Objects - Kamills-12/2143-OOP GitHub Wiki

Classes and Objects

Kade Miller


What’s a Class?

A class is basically the blueprint. You're not making the actual thing — you're just describing what it should be like. It’s like planning out a character in a game: name, stats, weapons, but you haven’t actually dropped them into the game yet.

Think of it like this: The class is the idea. The object is the real thing made from that idea.


What’s an Object?

An object is an actual thing built from that class. It's the working version; the car that’s been built from the blueprint, the NPC that actually spawns in the game.

You use the class to spawn as many objects as you want, each with their own stats, actions, etc.


Quick Example in C++

#include <iostream>
using namespace std;

class Dog {
public:
    string name;

    void bark() {
        cout << name << " says: Woof!" << endl;
    }
};

int main() {
    Dog myDog;
    myDog.name = "Titan";
    myDog.bark();  // Output: Titan says: Woof!

    return 0;
}
⚠️ **GitHub.com Fallback** ⚠️