नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'member' : cannot take the address of a non-static data member or method of a managed or WinRT type
Remarks
An instance is needed to take the address of nonstatic data members of a managed or WinRT class or interface.
Example
The following example generates C2843 and shows how to fix it:
// C2843_2.cpp
// compile with: /clr
public ref class C {
public:
int m_i;
};
ref struct MyStruct {
static void sf() {}
void f() {}
};
int main() {
MyStruct ^ps = gcnew MyStruct;
void (__clrcall MyStruct::*F1)() = & MyStruct::f; // C2843
void (__clrcall MyStruct::*F2)() = & ps->f; // C2843
void (__clrcall MyStruct::*F3)(); // C2843
void (__clrcall *F5)() = MyStruct::sf; // OK
void (__clrcall *F6)() = & ps->sf; // OK
interior_ptr<int> i = &C::m_i; // C2843
C ^x = gcnew C();
interior_ptr<int> ii = &x->m_i;
}