Created
April 21, 2015 13:16
-
-
Save kusano/53f6e8f2ef0ff06e77e5 to your computer and use it in GitHub Desktop.
メンバ変数への汎用ポインタ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct A { | |
int a; | |
}; | |
int main() | |
{ | |
A a; | |
int *p0 = &a.a; // OK | |
void *p1 = &a.a; // OK | |
int A::*p2 = &A::a; // OK | |
void A::*p3 = &A::a; // NG | |
void *p4 = (void *)&A::a; // NG | |
// エラー: invalid cast from type ‘int A::*’ to type ‘void*’ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment