[C++ Primer] 练习2.18

2017-02-17  本文已影响0人  和平北路
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
    int ival1 = 10;
    int ival2 = 20;
    int *p = 0;
    cout << p << endl;

    p = &ival1;
    cout << p << endl;
    cout << *p << endl;

    *p = ival2;
    cout << ival1 << endl;
    cout << ival2 << endl;

    p = &ival2;
    cout << p << endl;
    cout << *p << endl;
    cout << ival1 << endl;
    cout << ival2 << endl;

    return 0;
}
上一篇下一篇

猜你喜欢

热点阅读