Coupon Accepted Successfully!


Overloading main() Functions

In the last two subtitles, we learnt how to make main() as member function and how to overload member function. Like other member function, main() can be overloaded in the class body as a member function. The following program explains this concept:

8.38 Write a program to declare main() as a member function and overload it.


Explanation: This program is same as the previous one. Here, the main() function is used as a member function and it is overloaded for integer, float, and character.

It is not possible to overload the non-member main() function, which is the source of the C/C++ program and hence the following program will not be executed and displays the error message “Cannot overload ‘main’”.


Tip: The main() is the only function that cannot be overloaded.

Test Your Skills Now!
Take a Quiz now
Reviewer Name