:
struct X {
void f(int);
int a;
};
struct Y;
int X::* pmi = &X::a;
void (X::* pmf)(int) = &X::f;
double X::* pmd;
char Y::* pmc;
declares
pmi,
pmf,
pmd
and
pmc
to be a pointer to a member of
X
of type
int,
a pointer to a member of
X
of type
void(int),
a pointer to a member of
X
of type
double
and a pointer to a member of
Y
of type
char
respectively
. The declaration of
pmd
is well-formed even though
X
has no members of type
double. Similarly, the declaration of
pmc
is well-formed even though
Y
is an incomplete type
. pmi
and
pmf
can be used like this:
X obj;
obj.*pmi = 7;
(obj.*pmf)(7);
—
end example