Classes and Objects
Classes are user-defined data types that represent real-world entities. Objects are instances of classes.
class Car {
public:
string brand;
void honk() {
cout << "Beep!\n";
}
};
int main() {
Car myCar;
myCar.brand = "Toyota";
myCar.honk();
}
This is the foundation of OOP in C++.