What does & Type :: variable mean?

int main()
{
    struct Bob
    {
        int a;
    };

    &Bob::a;
}

      

What does it mean &Bob::a

? Bob is a type, not an instance, so he takes an address?

+3


source to share


1 answer


It is a pointer to a member of the class. According to the standard (N4296, 5.3.1):



The result of a unary operator &

is a pointer to its operand. The operand must be lvalue or identified-id. If the operand is a qualified identifier naming a non-static or variant member of m

some class C

with a type T

, the result is of type "pointer to member of C

type class T

" and is a denoting prvalue C::m

.

+2


source







All Articles