編譯器錯誤 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();
}
};
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應