VC++ 中的switch

今天写程序发现一个比较奇怪的VC++编译器规则,是对于switch的,在VC2005中:

 

int i=3;

 

switch(i)

{

case 0:

int j;        // It’s ok, but if you initialize the variable j here, for example we write int j=2; here ,

              // an error is given by the compiler (C2360)

j=2;

break;

case 1:

break;

case 2:

break;

case 3:

break;

}

 

By Lu Jun

80后男,就职于软件行业。习于F*** GFW。人生48%时间陪同电子设备和互联网,美剧迷,高清视频狂热者,游戏菜鸟,长期谷粉,临时果粉,略知摄影。

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.