Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.02 KB

compiler-error-c2597.md

File metadata and controls

40 lines (31 loc) · 1.02 KB
descriptiontitlems.datef1_keywordshelpviewer_keywordsms.assetid
Learn more about: Compiler Error C2597
Compiler Error C2597
11/04/2016
C2597
C2597
2e48127d-e3ff-4a40-8156-2863e45b1a38

Compiler Error C2597

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 pass in or create a local 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. Check identifier spelling.

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

  4. The following sample generates C2597 and shows how to fix it:

// C2597.cpp// compile with: /cstructs1 { staticvoidfunc(); staticvoidfunc2(s1&); int i; }; voids1::func() { i = 1; // C2597 - static function can't access non-static data member } // OK - fix by passing an instance of s1voids1::func2(s1& a) { a.i = 1; }
close