The composition is when one thing includes another object and the contained object cannot exist without the presence of the other object. Simply said, the composition is a type of aggregation that is used to express the relationship between two classes via the reference variable.
A class student, for example, may include another class named address. As a result, if the class address cannot exist without the class student, a composition exists between them.
Composition is the term describing a “has-a” relationship, just as inheritance describes an “is-a” relationship. A car is a vehicle, but has an engine, a steering wheel, &c.: A class describing a car would relate to the vehicle class by inheritance, but by the classes representing engines, steering wheels, and so on through composition. (In implementation terms, it basically just means that a class that includes another class by composition has member variables of that other class.)