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: 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; }

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 * . 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 * ?

> CV T , "where T is an object type, it should be" from

cv zero < / Code> "can be converted into type.

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.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -