我遇到了这个程序的问题。我试图使用嵌套的switch语句。为什么这个嵌套的switch语句不起作用? (C++)
void main()
{
int function_select, log_select, root_select ;
do
{
cout << "Please select the function you would like to use \n 1 : Logarithm \n 2 : Root \n 0 : Quit" << endl;
cin >> function_select;
switch (function_select)// main menu
{
case 1:// log menu
{
cout << "Please select which logarithm function you would like to perform \n 1 : Common Log \n 2 : Natural Log \n 3 : Log Base n \n 0 : Back" << endl;
switch (log_select)
{
case 1://common log
{
}
break;
对不起,看起来有点乱。我对C++仍然很陌生。这个程序还有更多,但我知道这个问题在这一节。当我运行该程序时,我收到一个错误,指出变量log_select
正在被使用而未被初始化,即使我在主程序中初始化了它。任何可以解决这个问题的建议?如果你能解释为什么这不起作用,我会很感激。
_“尽管我在主程序中初始化了它”_你显然没有。你能显示你初始化它的位置吗? – 2014-10-17 00:09:16