<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>选择 on My Blog</title>
    <link>http://localhost:1313/tags/%E9%80%89%E6%8B%A9/</link>
    <description>Recent content from My Blog</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    
    <managingEditor>3453434429@qq.com (ArenBase)</managingEditor>
    <webMaster>3453434429@qq.com (ArenBase)</webMaster>
    
    <copyright>本博客所有文章除特别声明外，均采用 BY-NC-SA 许可协议。转载请注明出处！</copyright>
    
    <lastBuildDate>Wed, 18 Mar 2026 00:00:00 +0000</lastBuildDate>
    
    
    <atom:link href="http://localhost:1313/tags/%E9%80%89%E6%8B%A9/index.xml" rel="self" type="application/rss&#43;xml" />
    

    
    

    <item>
      <title>关switch语句中case语句后加不加大括号{}的风险</title>
      <link>http://localhost:1313/post/switch%E8%AF%AD%E5%8F%A5%E4%B8%ADcase%E8%AF%AD%E5%8F%A5%E5%90%8E%E5%8A%A0%E4%B8%8D%E5%8A%A0%E5%A4%A7%E6%8B%AC%E5%8F%B7%E7%9A%84%E9%A3%8E%E9%99%A9/</link>
      <pubDate>Wed, 18 Mar 2026 00:00:00 &#43;0000</pubDate>
      <author>3453434429@qq.com (ArenBase)</author>
      <guid>http://localhost:1313/post/switch%E8%AF%AD%E5%8F%A5%E4%B8%ADcase%E8%AF%AD%E5%8F%A5%E5%90%8E%E5%8A%A0%E4%B8%8D%E5%8A%A0%E5%A4%A7%E6%8B%AC%E5%8F%B7%E7%9A%84%E9%A3%8E%E9%99%A9/</guid>
      <description>
        <![CDATA[<h1>关switch语句中case语句后加不加大括号{}的风险</h1><p>作者：ArenBase（3453434429@qq.com）</p>
        
          <h2 id="case的本质">
<a class="header-anchor" href="#case%e7%9a%84%e6%9c%ac%e8%b4%a8"></a>
case的本质：
</h2><p><code>case</code> 只是一个标签（label），并不会隐式创建新的作用域。（想象成一个不自动关门的“标记”）</p>
<p>如果你在一个 <code>case</code>的标记下面，直接写一句 <code>auto it = ...</code>或 <code>int x = 0</code>来声明并初始化一个变量，编译器就会报错（提示：“跨越初始化”）。它怕的是：如果程序执行时，从别的地方“跳”到了这个 <code>case</code>标记的下一行，那就跳过了你初始化变量的那一步。一个变量没初始化就被用，是很危险的，所以编译器干脆禁止你这么做。</p>
        
        <hr><p>本文2026-03-18首发于<a href='http://localhost:1313/'>My Blog</a>，最后修改于2026-03-18</p>]]>
      </description>
      
        <category>C&#43;&#43;</category>
      
    </item>
    
  </channel>
</rss>
