[ create a new paste ] login | about

Link: http://codepad.org/6c07RgKf    [ raw code | output | fork ]

johannes - C++, pasted on Nov 2:
#include <iostream>

int main()
{
    int *p[2];

    int *a = new int;
    *a = 21;
    int *b = new int;
    *b = 22;

    p[0] = a;
    p[1] = b;

    std::cout << *p[0] << std::endl;          // 21
    std::cout << *p[1] << std::endl;          // 22

    int **q = p;

    std::cout << **q << std::endl;
    std::cout << **(q + 1) << std::endl;

    delete a;
    delete b;

    return 0;
}


Output:
1
2
3
4
21
22
21
22


Create a new paste based on this one


Comments: