I know that I can get a pointer to a data element for a class or structure, but the last line of the following code does not compile:
struct abc { int a; int b; char c; }; int main() { typedef struct abc abc; char abc::*ptt1 = &abc::c; void *another_ptr = (void*)ptt1; }
Why can't I convert ptt1 to another_ptr? We are talking about pointers, so one pointer should have the same size as the other (although conceptually different)
; -. *. , .* ->*. , , , *?
*
.*
->*
void* (§4.10):
void*
" cv T", T , prvalue " cv void".
T
void
, , , "" (§3.9.2):
, , "", .
, , , . , void*, . , , size_t, a void* , a size_t. , , . , , , , , .
size_t
void* . , ( a char*), ( - ).
char*
Are you trying to do something like this?
struct ABC { int a; int b; char c; }; int main() { ABC abc; char *ptt1 = &abc.c; void *another_ptr = (void*)ptt1; }