Here has been a discussion about the usage of pointer to data member
As far as i know,the pointer to data member like int A::* p
does not reserve a real address of that member,but an offset instead.
However,i've come across a strange situation as follows:
class TEST
{
int k;
};
int main()
{
double TEST::* p;//why?
}
How could the above snippet be compiled without error,since there are actually no double type member of TEST class?(no diagnostic required?)
What's more,the cout<<p;
could also ran without error,although it may be an undefined behavior.