先看下以下代码

#include<iostream>
using namespace std;

int x = 1;

int f1()
{
    x = 2;
    return x;
}

int f2()
{
    x = 3;
    return x;
}

int main()
{
    //Test1
    cout << x << ' ' << f1() << ' ' << f2() << endl;    //2 2 3

    //Test2
    int i = 0;
    
    cout << i++ << ' ' << i << ' ' << ++i << endl;    //1 2 2
    
    //Test3
    int s[] = {1, 2, 3};

    int *p = s;
    
    //cout << *p << ' ' << *(p++) << ' ' << *(++p) << endl;    //3 2 3

    //cout << *p++ << ' ' << *++p << ' ' << *p << endl; //2 3 3

    //cout << *p << ' ' << *++p << ' ' << *p << endl; //2 2 2

    //cout << *++p << ' ' << *p << ' ' << *++p << endl; //3 3 3

    //cout << *p++ << ' ' << *p << ' ' << *p++ << endl; //2 3 1

    //cout << *p << " " << *p++ << " " << *p << endl;//2 1 2
}
View Code

相关文章: