Suppose I have two classes:
class A
{
int x;
int y;
};
class B
{
int z;
A ref;
};
Suppose I also have a function that accepts a pointer-to-member integer of B, like so:
void doSomethingToB(B* object, int B::* val)
{
if(val)
{
std::cout << object.*val;
}
}
Would there be a way that I could point to a member of ref
inside B?
Like, int B::* ptr = &(B::ref.x)
or something similar?
B
why would you need pointers to it's members?