Pointer to class member

1
2
3
4
5
int cl::*d; //pointer to class member
int *p; 
cl o; 
p = &o.val // this is address of a specific val
d = &cl::val // this is offset of generic val 


I don't understand the meaning of specific val and generic val ?
Can anyone explain ? Thanks
p is just a regular pointer to an int pointing to a specific int object. You can make p point to any int object.

d does not point to any specific int object. Instead it points to a specific int member of cl for any cl object. It needs a cl object to be useful. You can use it to access the int member (val) of o by doing o.*d.
Last edited on
Thanks for replying..
Topic archived. No new replies allowed.