User Tools

Site Tools


, ,

Referense and pointer differense

ref.cpp
/*
 * Author, Copyright: Oleg Borodin <onborodin@gmail.com>
 */
 
#include <iostream>
 
using namespace std;
 
int main(int argc, char **argv) {
 
    int i = 1;
    int& n = i;
    int* m = &i;
 
    i = 3;
 
    cout << i << endl;
    cout << n << endl;
    cout << *m << endl;
 
    cout << &i << endl;
    cout << &n << endl;
    cout << m << endl;
    cout << &m << endl;
 
    return 0;
}

Out

3
3
3
0x7fffffffe634
0x7fffffffe634
0x7fffffffe634
0x7fffffffe628