c++ - Convert pointer to data member to void * -
I know that I can get an indicator for a class or structure for the data member, but the following code Last line fails compiled: Why can not I convert ptt1 to another_ptr? We are talking about pointers, so a pointer should have the same dimension as each other (though conceptually different) A Pointer is not equal to non-static class member type an object pointer type ; They behave very differently. In fact, you can not even remove an indicator with the member for > CV cv They are so different that the standard also comes out of their way to make sure that non-static member (§ 3.9.2) in the word "pointer": < Blockquote> Exclude static members, not to the point of viewers, to the point of view of "pointers" to the participants. straight ABC {int a; Int b; Four c; }; Int main () {typedef struct abc abc; Four ABC :: * ptt1 = & amp; ABC :: C; Zero * another_ptr = (Zero *) ptt1; }
* . To make a member access the member through an indicator, you can replace the
* and
- & gt; * use operators. If you might be put it in an object pointer type, what would happen, if you deleted it from
* ?
T , "where
T is an object type, it should be" from
zero < / Code> "can be converted into type.
Comments
Post a Comment