नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'symbol' : is not a type name, static, or enumerator
Remarks
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.
When compiling with /clr, a common cause for C2327 is a property with the same name as the property type.
Examples
The following example generates C2327:
// 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 occur if the name of a type is hidden by the name of a member:
// C2327b.cpp
class X {};
class S {
X X;
// try the following line instead
// X MyX;
X other; // C2327, rename member X
};
C2327 can also fire in this situation, where you need to fully specify the data type of the parameter:
// C2327c.cpp
// compile with: /c
struct A {};
struct B {
int A;
void f(A a) { // C2327
void f2(struct A a) {} // OK
}
};
The following example generates C2327:
// C2327d.cpp
// compile with: /clr /c
using namespace System;
namespace NA {
public enum class E : Int32 {
one = 1,
two = 2,
three = 3
};
public ref class A {
private:
E m_e;
public:
property E E {
NA::E get() {
return m_e;
}
// At set, compiler doesn't know whether E is get_E or
// Enum E, therefore fully qualifying Enum E is necessary
void set( E e ) { // C2327
// try the following line instead
// void set(NA::E e) {
m_e = e;
}
}
};
}
The following example shows C2327 when a property has the same name as the property type:
// C2327f.cpp
// compile with: /clr /c
public value class Address {};
public ref class Person {
public:
property Address Address {
::Address get() {
return address;
}
void set(Address addr) { // C2327
// try the following line instead
// set(::Address addr) {
address = addr;
}
}
private:
Address address; // C2327
// try the following line instead
// ::Address address;
};