我读到C++标准禁止递归main(),但是g ++编译以下代码而没有抱怨:
int main()
{
main();
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以澄清这个吗?
C++03 3.6.1.3:函数main不得在程序中使用(3.2)....
我想知道为什么这个规则存在...是否有人知道任何系统/实现,如果使用main,它将是一个问题?
PS 1.我知道该术语的定义used.2.我知道有一些简单的解决方法,比如从main()调用单个MyMain()并使用MyMain()代替.3.问题是关于现实世界的实施,如果不存在限制则会产生问题.谢谢!
#include <iostream>
int main()
{
main();
std::cout<<"Hello World! "<<std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是代码,它的表现如何?为什么?
嗨,我只在尝试启动C时为植物大战僵尸教练编写代码,但由于以下错误而失败:
错误:无法将参数'2'的'LPCWSTR {aka const wchar_t *}'转换为'LPCSTR {aka const char *}'到'HWND __ * FindWindowA(LPCSTR,LPCSTR)'|
这是我的代码:
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
system("color 0A");//change the colour of the text
cout << "PlantsVsZombies Trainer voor game of the year edition(gemaakt door Pjotr Slooff)" << endl;//display some (dutch) text
cout << "Open PlantsVsZombies en druk dan op enter" << endl;
system("Pause");//wait for the user to press enter
LPCWSTR Game = L"Plants vs. Zombies";
HWND hwnd = FindWindowA(0, Game);
if (hwnd …Run Code Online (Sandbox Code Playgroud)