One of the main advantages of the C + + language is that, unlike its predecessor, language C, it is designed to support object-oriented programming (OOP).
This is a fairly simple concept: you will manipulate different objects, each of which is an instance of a particular class.
A class is a set of methods (functions bound to this class) and attributes (or data members, conceptually very close to the C struct).
The C + + structure behaves almost like the C + + class, but each of its components is public by default.
Using an example of a class would be clearer, let's assume we'll start designing an object that represents a vehicle:
Next is the constructor, which is a mandatory method that indicates how the class is instantiated.
It is called whenever an instance of the class is declared or created (using the new operator). Constructors can have parameters.
And then the destructor.
In most cases, both are declared in the public section.
C + + OOP