devxlogo

Overloading the Function Call Operator

Overloading the Function Call Operator

Overloading the function call operator can be somewhat confusing because the overloaded operator has two pairs of parentheses. It may not be immediately obvious which of these pairs declares the parameters. Another point to note is that the overloaded function call operator may take any number of arguments whereas all other overloaded operators take a fixed number of arguments. This example shows how you can overload the () operator and use it:

 class A{ private:   int n;public:  //

devx-admin

Share the Post: