主函数所在cpp:
#include "menu_1.cpp"
#include "menu_2.cpp"
void main(){
char choice;
do{
choice=_getch();
}while(choice!='0'&&choice!='1')
switch(choice)
case '0':
menu_1();
case '1':
menu_2();
}
menu_1()所在menu_1.cpp:
void menu_1(){
//其他操作
char choice;
do{
choice=_getch();
}while(choice!='0'&&choice!='1')
switch(choice)
case '0':
exit(0);
case '1':
menu_2();
}
menu_2()所在menu_2.cpp:
void menu_2(){
//其他操作
char choice;
do{
choice=_getch();
}while(choice!='0'&&choice!='1')
switch(choice)
case '0':
exit(0);
case '1':
menu_1();
}
由于作业需要,必须将menu_1和menu_2放在两个cpp文件中,但按我那样在主函数前声明的话,编译时会在menu_1.cpp中menu_2();那一行显示无法识别标识符menu_2(),哪位老虾帮帮忙,指点下该怎么声明?
编辑环境是VisualStudio2008
一下为一个简单的例子:
// file C.h