Skip to content

Instantly share code, notes, and snippets.

@kusano
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save kusano/e806c3ab4e3a68a2bf41 to your computer and use it in GitHub Desktop.

Select an option

Save kusano/e806c3ab4e3a68a2bf41 to your computer and use it in GitHub Desktop.
メンバ変数への汎用ポインタ
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