Why calling main() is not allowed in C++

后端 未结 3 630
离开以前
离开以前 2020-11-30 15:05

C++03 3.6.1.3: The function main shall not be used (3.2) within a program. ...

I wonder why this rule exists... Is anyone awa

3条回答
  •  一个人的身影
    2020-11-30 15:51

    C++'s main() is a strange little function that has different syntax for exception-handling, doesn't have to return a value, even though it has to be defined as returning int, etc. I don't know whether this affects any real implementations, but I would guess that the restriction exists to give compiler writers some latitude in how they implement main().

提交回复
热议问题