++与++

来源:互联网 发布:js 单选框选中 编辑:程序博客网 时间:2024/04/23 21:34

要联系有写博客的习惯。。。


直接贴代码了,需要注意的小细节


char* p = "abc"; char* p1 = "def"; cout << *(p++) <<endl;cout << *(++p1) <<endl;  

输出:a  e

龙龙龙说注意表达式值和变量值的区别

就相当于

char* p = "abc";char* p1 = "def"; char* tmp = p++;char* tmp1 = ++p1;cout << *tmp <<endl;cout << *tmp1 <<endl;  

这样比较好理解,还有一个括号的问题


int a=1; int b1=1; int b=a++; int c=(b1++);if (b == c)    cout<<"yes\n";else    cout << b <<"  " << c << "no\n";


输出的是yes
0 0