main函数标准写法

main函数签名

C++中允许两种格式,带参数的和不带参数的:

  1. int main()
  2. int main(int argc, const char* argv[])

和C标准不同,C++中main函数必须写明返回类型为int,不支持main默认返回int类型这一规定。
同时和C标准一样,若main函数中没有返回语句,那么最后默认添加上return 0;语句

posted @ 2020-04-06 16:17  HachikoT  阅读(574)  评论(0编辑  收藏  举报