OOP vocabulary
Class
A class is an extensible program-code-template for creating objects. The class is the "mould" of an object.
When an object is placed in a program, it is called an instance of the class.
Objects of the same class will have the same properties but with different values.
Example :
In this program there are three buttons. TSpeedButton is the class and SpeedButton1, SpeedButton2, SpeedButton3 are instances of this class.
For each instance, the glyph propertie (the button picture) is different.
Inheritance
The inheritance is a mechanism by which we define a class of object as being a particular case of a more general class.
Thanks the inheritance, it is possible to reuse the code and to develop complex softwares in a short time.
Exemple
Vehicle is an objet with 3 properties : COLOR, POWER_ENGINE, NUMBER_OF_PASSENGERS and 2 methods START() and REFUEL().
The objects CAR, PLANE and BOAT inherit the properties and the Methods of VEHICLE.
They have also their own methods
Encapsulation
L'encapsulation est un mécanisme consistant à rassembler les données et les méthodes au sein d'une structure en cachant l'implémentation de l'objet, c'est-à-dire en empêchant l'accès aux données et aux codes informatiques par un autre moyen que les services proposés.
L'encapsulation permet donc de garantir l'intégrité des données contenues dans l'objet.
Pour ce faire, lors de l'écriture des classes on dispose de trois niveaux de lisibilité :
QT Creator :
Messages
En programmation objet, les objets s'animent grâce aux méthodes.
Les méthodes sont activées grâce à des messages qui leur sont envoyés.
Les messages peuvent provenir