wine习得知识小记
1、
VS2008:
sizeof cout:56sizeof cin:60
sizeof streamsize: 4
VS2012
sizeof cout:80
sizeof cin:96
sizeof streamsize: 8
这样就很明显了,为了支持大的stream而故意引入streamsize的改变。
2、
以前初学C\C++用pow函数的时候也有点疑惑,
Let‘s count the ways the hypthetical int pow_int(int, int) function could fail.
Overflow
Result undefined pow_int(0,0)
Result can‘t be represented pow_int(2,-1)
The function has at least 2 failure modes. Integers can‘t represent these values, the behaviour of the function in these cases would need to be defined by the standard - and programmers would need to be aware of how exactly the function handles these cases.
3、
花括号其实是为了定义变量……
加上了花括号的话,里面的变量只在这个花括号里有用。
case 1:{int a;break;}
case 2:{int a;break;}
否则就得
case 1:int a;break;
case 2:int b;break;
值得注意的是,C85 里是不允许在任意地方定义变量的,必须放在一个复合语句的起始部分。