This documentation is archived and is not being maintained.

Compiler Warning (level 1) C4253

Visual Studio .NET 2003

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

A pointer to a non-static member function of a class or structure must have the form of an & followed by the qualified identifier not enclosed in parentheses. This warning is only issued under /Za.

The following sample generates C4253:

// C4253.cpp
// compile with: /Za /W1
#include <stdio.h>

struct A {
   void f() {
      printf("test");
   }
};

int main() {
   A a;
   A *as = new A;

   void (A::*p3)() =  A::f; // ok with -Ze, warning with -Za
   // the following line shows how to assign a pointer to a class member
   // from outside the class
   // void (A::*p3)() = &A::f;

   // C4253 expected, calling member function from outside the class
   (as->*p3)();
}
Show: