小编zan*_*naM的帖子

Lua语言中switch语句的替代方法是什么?

我在C++中有这段代码,我想知道如何编写一些替换Lua中的switch语句的代码,因为我遇到了很多问题,我需要使用这个语句.

   int choice;
do// loop
{
      cout<<"\n >>> The General Menu <<< \n";
      cout << endl;
    cout<< " press (1) to Add    "<<endl;
    cout<< " press (2) to Save   "<<endl;
    cout<< " press (3) to Quit " << endl;
    cout<< endl;
      cout<< "Enter your choice please (1/2/3): ";
    cin>>choice;

    switch(choice)
    {
        case 1: 
            add();
            break;
        case 2:
            save();
            break;

        default:
            cout<<" The program has been terminated "<<endl;
           cout<<" Thank you! \n";          
    }   
} while (choice != 3);
Run Code Online (Sandbox Code Playgroud)

该语句已在do..while循环中使用.

lua switch-statement

6
推荐指数
3
解决办法
2万
查看次数

标签 统计

lua ×1

switch-statement ×1