我有这个工作代码:
/* Include files */
#include <iostream>
#include <string>
#include <limits>
using namespace std;
void fnMainMenu(char s);
/******************************************************************************
* Function: fnUpdateSalary
* Description: Update employee salary
******************************************************************************/
void fnUpdateSalary()
{
int choice = 0;
char data = 'a';
incorrect_input: // goto teleport exit :)
cout<<"\n\t=======================";
cout<<"\n\tWelcome\n";
cout<<"\t=======================\n\n";
cout<<"1. Update employee salary\n";
cout<<"2. Main menu\n";
cout<<"3. Exit system\n";
cout<<"\n >> ";
cin>>choice;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
switch(choice){
case 1 :
//fnUpdateSalary();
break;
case 2 :
fnMainMenu(data);
break;
case 3 :
exit(1);
break;
default :
cout<<"Input not recognized. Please enter the correct input.\n";
}
}
void fnLog()
{
char data = 'b';
fnMainMenu(data); // call Main Menu and I want to pass "hello"
}
/******************************************************************************
* Function: fnMainMenu
* Description: Menu for the customer
******************************************************************************/
void fnMainMenu(char s)
{
cout << s;
if (s == 'a')
{ cout << "a = admin";
}
else
{cout << "\n\nb not admin";
}
//system("cls");
int chooice = 0;
cout<<"\n\t=======================";
cout<<"\n\tWelcome\n";
cout<<"\t=======================\n\n";
cout<<"1. Manage employee\n";
cout<<"2. Search employee\n";
cout<<"3. Employee report\n";
cout<<"4. Reset password\n";
cout<<"5. Exit system\n";
cout<<"\n >> ";
int numbers = 2;
cin>>chooice;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
switch(chooice){
case 1 :
fnUpdateSalary();
break;
case 4 :
// fnChangePassword();
break;
default : exit(1);
}
}
/******************************************************************************
* Function: main
* Description: The main calling function
******************************************************************************/
int main()
{
fnLog();
return 0;
}
fnLog()
发送b
到fnMainMenu()
. 当我在时,fnUpdateSalary()
我想再去fnMainMenu()
一次。我的问题是,在不再次声明变量的情况下,是否有fnUpdateSalary()
任何可调用的函数?我希望我可以使用而不是 fnMainMenu()
data
fnMainMenu();
char data = 'r'; fnMainMenu(data);
error C2660: 'fnMainMenu' : function does not take 0 arguments
如果我刚刚打电话,我会收到此错误fnMainMenu();
我希望我的问题有意义。提前致谢。