int main()
{
struct Bob
{
int a;
};
&Bob::a;
}
What does &Bob::a
mean? Bob is a type and not an instance, so what is it taking the address of?
int main()
{
struct Bob
{
int a;
};
&Bob::a;
}
What does &Bob::a
mean? Bob is a type and not an instance, so what is it taking the address of?
It is a pointer to a member of class. According to the standard (N4296, 5.3.1):
The result of the unary
&
operator is a pointer to its operand. The operand shall be an lvalue or a qualified-id. If the operand is a qualified-id naming a non-static or variant memberm
of some classC
with typeT
, the result has type “pointer to member of classC
of typeT
” and is a prvalue designatingC::m
.