This documentation is archived and is not being maintained.

Compiler Error C2597

Error Message

illegal reference to non-static member 'identifier'

Possible causes:

  1. A nonstatic member is specified in a static member function. To access the nonstatic member, you must create an instance of the class and use a member-access operator (. or ->).

  2. The specified identifier is not a member of a class, structure, or union.

  3. A member access operator refers to a nonmember function.

  4. The following sample generates C2597:

// C2597.cpp
// compile with: /c
struct s1 {
   static void func();
   int i;

void s1::func() {
   i = 1;    // C2597

   // OK
   s1 a;
   a.i = 1;