NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Error C2475

'member_name' : forming a pointer-to-member requires explicit use of the address-of operator (‘&’) and a qualified name

Accessing a member of a class from outside the class requires the scope resolution operator (::) and the address of (&) operator. The following sample generates C2475:

#include <stdio.h>

struct A {
   void f() {
      printf("test");
   }
   void g();
};
 
void A::g() {
   void (A::*p1)() = f;      // ok in -Ze; error in -Za (C2475)
   void (A::*p5)() = this->f;   // error: C2475

   // the following line shows how to call a function from outside the class
   // void (A::*p4)() = &A::f;
}

int main() {
   A *ap = new A;
   A a;   
   void (A::*p5)() = a.f;       // error: C2475

   // the following line shows how to call a function from outside the class
   void (A::*p4)() = &A::f;

   // the following line shows how to call a member function
   (ap->*p4)();
   return 0;
}