main() in C, C++, Java, C#

前端 未结 9 1461
心在旅途
心在旅途 2020-12-11 06:20

Is main() (or Main()) in C, C++, Java or C#, a user-defined function or a built-in function?

9条回答
  •  攒了一身酷
    2020-12-11 06:33

    I'm not sure what you mean by built-in vs. user defined. Almost no language actually gives your user-defined function the privilege of being the true entry-point into the program. C++, any .NET language, and Java all have hidden (built-in) entry point methods that in turn call your user-defined Main method (or whatever the entrypoint method for that language is called -- in .NET it can be named anything, although C# and VB.NET force it to be called Main).

    So yes, virtually every language has a concept of a method that is automatically called, and this method is a user-defined method and usually mandatory. But virtually every language also has a built-in entry point method that actually sets up the framework and/or memory management for the process before invoking your user-defined "entry-point" function.

提交回复
热议问题