Reuse: reusing the implementation
•When you have created an useful class, you can reuse its services not only declaring objects of the newly created data type, but also instantiating it inside of bigger classes •This relationship in OOP is called composition or aggregation and is depicted as follows in an UML diagram (which reads: a car has an engine)
http://www.alessandroogheri.com
Aggregation or composition is one of the two most important ways to reuse code in object oriented programming languages (the other is inheritance).
Aggregation is an operation which models a so called “has a” relationship, like in a car has an engine, which is exactly the example we shown two slides ago: this shows to you that the data members of a class do not have to be necessarily C++ basic data types (char, int, float, and so on…) but can be also instances of the data types that the user has defined by mean of the class keyword.
Actually, one of the major effort in the design of the C++ language was to let the user defined data types be as indistinguishable as possible from the “native” basic data types.