A lady behaves like a teacher in a classroom, mother or daughter in a home and
customer in a market. Here, a single person is behaving differently according to the
situations. Consider a above real-life example and which concept you will use in cpp.
Elaborate the concept.
The given case is the example of polymorphism in C++ programming language. It comes under the object oriented programming approach (OOPS). Polymorphism allows for a data to be available in different formats. For example, vehicle can be used to carry passengers, carrying goods or just for driving on plane roads. The same addition function can be used to add two integers, two floats or one int and one float. Similarly the the case of a women who is customer in the market, mother or sister in house and teacher in the class room. The related overload function are then invoked by comparing and matching the type of variable arguments. This is known at the compile time and appropriate function is selected to perform the desired operation.
Comments
Leave a comment