Overloading of function-call operator in C++
- The function call operator is denoted by “()” which is used to call function and pass parameters. It is overloaded by the instance of the class known as a function object.
- When the function call operator is overloaded, an operator function is created that can be used to pass parameters.
- It modifies that how the operator is fetched by the object.
- In Object-Oriented Languages, operator() can be treated as a normal operator, and objects of a class type can call function (named operator()) like making a function call to any other overloaded operator.
- When the function call operator is overloaded, a new way to call a function is not created rather an operator() function is created that can be passed an arbitrary number of parameters.
Below is the program of taking input in a matrix using friend functions first to overload insertion operator and extraction operator and then overloading operator() for taking input for the ith row and the jth column of the matrix and displaying value at the ith row and the jth column stored in the matrix: