sizeof()使用错例:sizeof(i++)

1 #include "iostream"
2
3 using namespace std;
4
5 int main(void)
6 {
7 int a = 1000;
8 printf("%d\n", sizeof(a++));
9 printf("%d\n", sizeof(++a));
10 printf("%d\n", a);
12 }

期望打印结果是什么?

g++ xxx.cpp -o a.out -std=c++11

【输出】

4

4

1000  //因为sizeof()里面的表达式不会被执行。

猜你喜欢

转载自www.cnblogs.com/atoman/p/11930614.html