两个主要功能 [英] Two main functions
本文介绍了两个主要功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以在C ++程序中有两个 main()
函数?
Can we have two main()
functions in a C++ program?
推荐答案
标准在3.6.1中明确说明:
The standard explicitly says in 3.6.1:
程序应包含一个名为main的全局函数,的程序。 [...]
A program shall contain a global function called main, which is the designated start of the program. [...] This function shall not be overloaded.
这个函数不能重载。 main
函数在程序的全局范围内。其他范围中也称为 main
的函数不受此影响,可以有任意数量的函数。
So there can one only be one one main
function in the global scope in a program. Functions in other scopes that are also called main
are not affected by this, there can be any number of them.
这篇关于两个主要功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文