Friday, March 4, 2011

C++ pointer, reference - **, *&, &&, &*


Let's think about pointer and reference with - &&, &*, ** and *&

  • int &&a;
    ILLEGAL : '&&' is a comparison syntax, not a pointer nor reference thing. Pass.

  • int &*a;
    ILLEGAL : (pointer-to-reference) Can't declare a pointer to int&. Reference is another name of an object(you can't set a pointer to a 'name').

  • int **a;
    pointer-to-pointer : You can use
    value(**a), pointer address(*a) and pointer's pointer address(a).

  • int *&a;
    reference-to-pointer : You can use
    value(*a), pointer address(a) and pointer's pointer address(&a).
Get confused :) ?

No comments:

Post a Comment