I'm writing a reflection utility for self usage, I simplified the code(remove complicated templates) as below:
class A {
private:
friend class Field;
int i;
};
class Field {
public:
Field(int A::* p) : p(p) {}
private:
int A::* p;
};
Field field(&A::i);
the compiler complains about i
is private of class A
.
I'm confused now, I know that parameters have a scope of function prototype scope, but I don't know much about it's relationship with the C++ feature friend classes.
Can anyone help what should I do to pass the private &A::i
to the field
object?