Classes are objects that contain their own variables and functions.
Classes are private by default, unlike structs which default to public.
Creating a class:

class Student{
private:
// Member variables
    string name; 
    int score;
    char grade;
public: 
// Member functions
    // Default constructor
    Student(); 
    // Parameterized constructor
    Student(string name, int score);
    // Copy constructor
    Shape(Shape const &obj);
    //Mutator/Setter functions
    void setStudentData();
    void setStudentData(string name, int score);
    //Accessor/Getter functions
    string getName() const;
    int getScore() const;
    // Other functions
    void calculateGrade();
    void printData();
    //Destructor function
    ~Student(); 
};

Default constructor:

Student::Student(){
    cout<<"Default Constructor Called"<<endl;
    name = " ";
    score = 0;
    grade = ' ';
}

Parameterized constructor:

Student::Student(string name, int score){
    cout<<"Parameterized Constructor Called"<<endl;
    this->name=name;
    this->score=score;
}

Copy constructor:

Shape::Shape(Shape const &obj){
    name = obj.name;
    score = obj.score;
    grade = obj.grade;
}
int main(){
	Shape s1;
	Shape s2 = s1;
}

Destructor:

Student::~Student(){
    cout<<"Destructor Called for "<<getName()<<endl;
}

Inheritance

“Is-a” relationship between classes.
Inheritance is when you have a class that inherits from another class.
For example, a Car class might inherit from a Vehicle class.
Consider you have a Vehicle Class:

class Vehicle{ /* some code */ }

This is called a parent class.
Then, you could have other classes for all the different vehicles you have:

class Car:public Vehicle{ /* some code */ }
class Plane:public Vehicle{ /* some code */ }
class Bike:public Vehicle{ /* some code */ }

These are called child classes.
This can be efficent because you would declare things such as model and year in the Vehicle class while having more specific information like numOfWheels and wingspan in the child classes.
Child classes cannot access private members of the parent class.
If you have the same function in the child and parent class, it will prioritize the child class.

Composition

“Has-a” relationship between classes.
Occurs when a class has a member variable that is itself another class.
Consider you have a Car class:

class Car{ /* some code */ }

You can then have it contain different classes for each part of the car:

class Car{ 
private:
    Engine engine;
    Radio radio;
    /* etc */
public:
    /* some functions */
}