What is the proper signature of the main function in C++? What is the correct return type, and what does it mean to return a value from main? What are the allowed parameter types, and what are their meanings?
这是系统特定的吗?这些规则会随着时间而改变吗?如果我违反它们会发生什么?
在C++ 11中,以下函数声明:
int f(void);
Run Code Online (Sandbox Code Playgroud)
意思是:
int f();
Run Code Online (Sandbox Code Playgroud)
由非依赖类型void的单个未命名参数组成的参数列表等效于空参数列表.
我得到(也许是错误的)印象这是一个旧功能,也许是从C继承而来的?
有没有人知道这种方式背后的历史或理由来声明一个没有参数的函数?