c ++ language a few pit

#include <iostream>

int main(){
        int i = 1;
        switch (i){
                case  1 :
                        int j ;
                        j = 1;
                        break;
                case 2:
                        std::cout<<j;
        }



}

  switch supports the definition of variables, and the other case is visible, so avoid problems, case should be wrapped in braces

Guess you like

Origin www.cnblogs.com/hustcpp/p/11122070.html