28 Ott 2002
Costruzione di Interfacce - Paolo Cignoni
31
•#include <iostream>
using namespace std;

int main(int argc, char **argv) {

    int myInteger = 1000;
    int *myIntegerPointer = &myInteger;

    // declare another integer whose value is the same as the integer
    // at memory address <myIntegerPointer>
    int mySecondInteger = *myIntegerPointer;

    // print the value of the first integer before changing it
    cout << myInteger << endl;

    // dereference the pointer and add 5 to the integer it points to
    *myIntegerPointer += 5;

    // print the value of the integer after changing
    // it through the pointer
    cout << myInteger << endl;

    // print the value of the second integer
    cout << mySecondInteger << endl;
}