編譯器錯誤 C3767
無法存取 『function』 候選函式
類別中定義的friend函式不應該被視為在全域命名空間範圍中定義和宣告。 不過,它可以透過自變數相依查閱找到。
C3767 也可能因為重大變更所造成:原生類型現在在 /clr 編譯中預設為私用;如需詳細資訊,請參閱類型可見性。
範例
下列範例會產生 C3767:
// C3767a.cpp
// compile with: /clr
using namespace System;
public delegate void TestDel();
public ref class MyClass {
public:
static event TestDel^ MyClass_Event;
};
public ref class MyClass2 : public MyClass {
public:
void Test() {
MyClass^ patient = gcnew MyClass;
patient->MyClass_Event();
}
};
int main() {
MyClass^ x = gcnew MyClass;
x->MyClass_Event(); // C3767
// OK
MyClass2^ y = gcnew MyClass2();
y->Test();
};
下列範例會產生 C3767:
// C3767c.cpp
// compile with: /clr /c
ref class Base {
protected:
void Method() {
System::Console::WriteLine("protected");
}
};
ref class Der : public Base {
void Method() {
((Base^)this)->Method(); // C3767
// try the following line instead
// Base::Method();
}
};