Export (0) Print
Expand All
Expand Minimize

Compiler Error C2327

'symbol' : is not a type name, static, or enumerator

Code within a nested class attempts to access a member of the enclosing class that is not a type name, a static member, or an enumerator.

Example

// C2327.cpp
int x;
class enclose {
public:
   int x;
   static int s;
   class inner {
      void f() {
         x = 1;      // C2327; enclose::x is not static
         s = 1;      // ok; enclose::s is static
         ::x = 1;    // ok; ::x refers to global
      }
   };
};

C2327 can also fire in this situation, where you need to fully specify the data type of the parameter.

// C2327b.cpp
struct A {
};

struct B {
   int A;
   void f(/*struct*/ A a) {   // C2327 uncomment struct to resolve
   }
};

C2327 can also occur when using Managed Extensions for C++:

// C23273.cpp
// compile with: /LD /clr
#using < mscorlib.dll >
#include < windows.h >
using namespace System;
namespace NA {
   public __value enum E : Int32 {
      one = 1, two = 2, three = 3
   };

   public __gc class A {
      E m_e;
      public:
         __property E get_E() {
            return m_e;
         }
         // At set_E compiler doesn't know whether E is get_E or 
         // Enum E, therefore fully qualifying Enum E is necessary
         __property void set_E(E e) {   // C2327
         // try the following line instead
         // __property void set_E(NA::E e) {
            m_e = e;
         }
   };
}
Show:
© 2014 Microsoft