Here’s a “valid” way of initializing such a monstrosity:
struct bar;
struct foo
{
int y;
int bar::* whatever;
};
struct bar
{
foo aFoo;
};
int bar::* foo::* ptr = &foo::whatever;
As we can see, ptr is a pointer to a member of foo (foo::*, reading right to left), where that member is itself a pointer to a member of bar (bar::*), where that member is an int.
How would I use an int bar::* foo::*
You wouldn’t, hopefully! But if you are under duress, try this!
struct bar
{
foo aFoo;
int really;
};
int bar::* foo::* ptr = &foo::whatever;
foo fleh;
fleh.whatever = &bar::really;
bar blah;
blah.*(fleh.*ptr) = 42;
std::cout << blah.really << std::endl;