Composition

Every big thing is made up of small-small things. For example, a house is built from walls, ceiling, and doors. Now in terms of C++, we can say that every complex object is built from small or simple object. This process of creating a complex object from simple and small objects is called composition in C++. In other words, whenever there is “has-a” relationship, then composition comes in to picture. E.g., house has four walls, two doors and one ceiling. Let us try to understand the concept of composition with…