1
Reply

What is function overloading and operator overloading?

Sapna Malik

Sapna Malik

15y
9.5k
0
Reply

    Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This capability is called function overloading. When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and order of the arguments in the call.Function overloading is commonly used to create several functions of the same name that perform similar tasks but on different data types.

    Operator overloading allows existing C++ operators to be redefined so that they work on objects of user-defined classes. Overloaded operators are syntactic sugar for
    equivalent function calls. They form a pleasant facade that doesn't add anything fundamental to the language (but they can improve understandability and reduce
    maintenance costs).

    when two or more functions share the same name as well parameters in both base class and derived class it is said to be function overloading.
    Normally we cant perform any arthematic operations on objects to provide this feature c++ comes with this mechanism.Polymarphism can be achevied through fun &operator overloading.