Say I have a class called ClothingStore. This class has 3 member functions that point the visitor to the correct department store. The functions of the members are ChildrenDept, MenDept and WomenDept, depending on whether the visitor is a child, a man or a woman.
Functional overload can be used to create three functions that have the same name, for example, PointToDept, but accept different input arguments (child, man, woman).
What actually happens during program execution?
I assume that the compiler adds switch statements to the program to select the correct member function. But this makes me wonder if there is any benefit in terms of program performance when using overloaded functions instead of doing your own function with switch statements? Again, my only conclusion in this part is code readability. Thanks.
source
share