指针的前置++与后置++的区别
//代码片段一:
int arr[] =
{1,2,3,4,5,6,7,8,9,10};
int* parr1 = arr;
int A = *parr1++;
int B =
*parr1;
cout << "A = " << A << endl;
cout << "B = " << B << endl;
输出结果:
A
= 1;
B = 2;
代码片段二:
int arr[] = {1,2,3,4,5,6,7,8,9,10};
int* parr1 = arr;
int A
= *++parr1;
int B = *parr1;
cout << "A = " << A << endl;
cout << "B = " << B << endl;
输出结果:
A
=
2
;
B
= 2;