C++解决case中不能定义局部变量问题

case Operation::DeviceAuthen:
{
    std::string token = root["body"]["token"].asString();
    std::string secretKey = root["body"]["secretKey"].asString();
    std::string resultMesg = root["head"]["resMessage"].asString();
    CMyINI *myINI = new CMyINI();
    myINI->SetValue("setting", "token", token);
    myINI->SetValue("setting", "secretKey", secretKey);
    myINI->WriteINI(GetProgramDir() + "\\UserInfo.data");
    delete myINI;
}

如上代码,只需要在case后加{}即可。

posted @ 2018-04-29 00:08  zhaogaojian  阅读(894)  评论(0编辑  收藏  举报