can any one help me?
is main() function a pre defined function or a user defined function?
thank you
Both? It's predefined in that you have to define it the way that C++ expects, but it's user defined in that you still have to define it. Does that make sense?
main is a function written by the user, but it is special in several ways. as per ISO/IEC 14882(E):
3.6.1-1a program shall contain a global function called main, which is the designated start of the program. ...
3.6.1-2 an implementation shall not predefine the main function. this function shall not be overloaded. it shall have a return type of type int, but otherwise its type is implementation-defined. all implementations shall allow both of the following definitions of main: int main() { /* ... */ } and int main(int argc, char* argv[]) { /* ... */ }
3.6.1-3 the function main shall not be used (called) within a program. The linkage of main is implementation-defined
so it is a function defined by the user; but unlike other user defined functions, it must be in the global namespace, it can not return anything other than an int, it cannot be overloaded, it cannot be called (implementation defined linkage, usually different from the linkage for other functions) and it need not contain a return statement (assumed return 0).
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.