function overloading in c++ how can we overload main?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhinav priyadarshi
    New Member
    • Sep 2010
    • 2

    function overloading in c++ how can we overload main?

    function overloading in c++ how can we overload main?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You can't. Not only can't you but I can think of no reason why you would want to.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Your program needs an entry point function. The loader will jump to that function so start the program.

      The default function is main().

      However, you can have an entry point function other than main. All you need to do is tell the linker the name of the function so the address of that function is loaded as the entry point to start the program.

      You can do this in the linker portion of the makefile, or with an IDE like Visual Studio, you set an entry point property to the correct function.

      This is not really an overload but is a sneaky way to have a program with no main().

      Comment

      Working...