“退出"不是全局名称空间错误的成员 [英] 'exit' is not a member of global namespace error
本文介绍了“退出"不是全局名称空间错误的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C ++中创建了一个应用程序(控制台应用程序),但是当我尝试构建它时出现错误:
"exit"不是全局名称空间的成员,
谁能告诉我该如何解决?
提前感谢...
I made an application in C++ (console app), but when i try to build it gives an error:
"exit" is not a member of global namespace ,
Can anyone tell me How to fix this ?
Thanx in advance...
推荐答案
添加头文件< stdlib.h>
喜欢,
Add header file <stdlib.h>
like,
#include <stdlib.h>
例如,
For Example,
#include <stdlib.h>
int main( void )
{
exit( 0 );
}
注意
Regards
在旁注中,除非程序遇到错误情况并且不能确保所有对象仍处于定义良好的状态,否则不应使用exit.从程序返回的首选方法是在main()
中调用return
.参见> http://stackoverflow.com/questions/461449/return-statement-vs-exit -in-main [ ^ ]
并不是说您使用的是错误的,但是解决方案2中的示例就是这种类型的-该代码应使用return
而不是exit
.
On a sidenote, you shouldn''t use exit unless your program ran into an error condition and you can not be sure all your objects are still in a well-defined state. The preferred way of returning from a program, is to callreturn
inmain()
. See http://stackoverflow.com/questions/461449/return-statement-vs-exit-in-main[^]
Not saying you are using it wrong, but the example in Solution 2 is of that type - that code should usereturn
rather thanexit
.
这篇关于“退出"不是全局名称空间错误的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文