0 votes
in C Plus Plus by

Explain Function Overloading and Operator Overloading.

1 Answer

0 votes
by

C++ supports OOPs concept Polymorphism which means “many forms”.

In C++ we have two types of polymorphism, i.e. Compile-time polymorphism, and Run-time polymorphism. Compile-time polymorphism is achieved by using an Overloading technique. Overloading simply means giving additional meaning to an entity by keeping its base meaning intact.

C++ supports two types of overloading:

Function Overloading:

Function overloading is a technique that allows the programmer to have more than one function with the same name but different parameter list. In other words, we overload the function with different arguments i.e. be it the type of arguments, number of arguments or the order of arguments.

Function overloading is never achieved on its return type.

Operator Overloading:

This is yet another type of compile-time polymorphism that is supported by C++. In operator overloading, an operator is overloaded, so that it can operate on the user-defined types as well with the operands of the standard data type. But while doing this, the standard definition of that operator is kept intact.

For Example, an Addition operator (+) that operates on numerical data types can be overloaded to operate on two objects just like an object of complex number class.

Related questions

0 votes
asked Jun 15, 2020 in C Plus Plus by Robindeniel
+2 votes
asked Jun 19, 2019 in C Plus Plus by anonymous
0 votes
asked Jun 15, 2020 in C Plus Plus by Robindeniel
...