我的错误:
|21|error: 'main' was not declared in this scope|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
我的实际程序完全不同并且更大(因此不需要标题)。我写这篇文章是为了快速展示我的问题。我如何摆脱该 void 函数的范围并返回 main (我的程序菜单实际所在的位置)?
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <limits>
int continueint;
using namespace std;
class handles {
public:
void continueChoice()
{
cout<<"[1] Go back to the main menu"<<endl;
cout<<"[2] Terminate the program"<<endl;
cin>>continueint;
switch (continueint)
{
case 1:
main(); // This is where my problem lies
case 2:
break;
}
}
}handlers;
int main(int nNumberofArgs, char*pszArgs[])
{
cout<<"A message here."<<endl;
system("PAUSE");
handlers.continueChoice(); //Calls the void function in the above class
}