Last active
August 29, 2015 14:19
-
-
Save kusano/e806c3ab4e3a68a2bf41 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 | |
| // (gcc) エラー: cannot declare pointer to ‘void’ member | |
| // (VC++) error C2182: 'a' : 'void' 型が不適切に使用されています。 | |
| // (VC++ (インテリセンス)) Error: 型 "void" のメンバーへのポインターは使用できません | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment