【C/C++】error: a label can only be part of a statement and a declaration is not a statement
来源:互联网 发布:修改telnet端口 编辑:程序博客网 时间:2024/05/26 02:54
http://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement
switch case:里不能声明变量
如果要声明需要给case加{}
Case statements are only 'labels'. This means the compiler will interpret this as a jump directly to the label. In C++, the problem here is one of scope. Your curly brackets define the scope as everything inside the 'switch' statement. This means that you are left with a scope where a jump will be performed further into the code skipping the initialization. The correct way to handle this is to define a scope specific to that case statement and define your variable within it.
0 0
- 【C/C++】error: a label can only be part of a statement and a declaration is not a statement
- C语言:error: a label can only be part of a statement and a declaration is not a statement|
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- error: a label can only be part of a statement and a declaration is not a statement
- ERROR:a label can only be part of a statement and a declaration is not a statement
- error: a label can only be part of a statement and a declaration is not a statement
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- switch引发的错误:a label can only be part of a statement and a declaration is not a statement
- 错误“a label can only be part of a statement and a declaration is not a statement”解决方法
- 错误“a label can only be part of a statement and a declaration is not a statement”解决方法
- switch 错误:a label can only be part of a statement and a declaration is not a statement
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- mac安装mysql数据库后忘记密码
- VLC的ACtiveX插件使用方法
- 聊聊设计模式 — 模板方法模式
- NOIp2009 最优贸易
- 新手入门一篇就够:从零开发移动端IM
- 【C/C++】error: a label can only be part of a statement and a declaration is not a statement
- C#之WinForm基础 使用代码让textbox换行
- Inner class
- java基础
- 从短信备份与还原理解如何降低代码的耦合性
- Android 监听软键盘的显示与隐藏
- Java并发编程(Java Concurrency)(6) - 并发 vs. 并行(Concurrency vs. Parallelism)
- 欧拉函数(数论)
- 缓慢的setfill和setw函数