我遇到了這個程序的問題。我試圖使用嵌套的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