what is composition in c++
It's an object design concept. Can you express composition in UML? The implementation is pretty much the same in most languages.
closed account (jwkNwA7f)
Game objects are often composed of other objects. For example, in a racing
game, a drag racer could be seen as a single object composed of other individual objects, such as a body, four tires, and an engine. Other times, you might see an object as a collection of related objects. In a zookeeper simulation, you might see the zoo as a collection of an arbitrary number of animals. You can mimic these kinds of relationships among objects in OOP using aggregation—the combining of objects so that one is part of another. For example, you could write a Drag_Racer class that has an engine data member that’s an Engine object. Or, you could write a Zoo class that has an animals data member that is a collection of Animal objects.
Topic archived. No new replies allowed.