Home › C++ Tutorial › C++ OOP, classes and objects
C++ OOP, classes and objects
Model things as objects.
A class bundles data (attributes) and functions (methods). Create objects from it. OOP gives encapsulation, inheritance, polymorphism and abstraction.
Example code
#include <iostream>
using namespace std;
class Car {
public:
string brand = "Tata";
int year = 2024;
};
int main() {
Car c;
cout << c.brand << " " << c.year << endl;
return 0;
}