C++ provides another operator ->* for use exclusively with pointers to members called member dereferencing operator. This operator is used to access a member using a pointer to it with pointer to the object. For example
Class X
{
int y;
public:
int a;
int b;
}
void main()
{
X *PO;
int X::*ptr; //
ptr = &PO::a; // int X::*ptr = &X::a;
PO->*ptr = 20;
int k = PO->*ptr;
}
No comments:
Post a Comment