__identifier (C++/CLI)
能夠使用 C++ 關鍵字作為識別碼。
所有平台
語法
__identifier(C++_keyword)
備註
允許針對不是關鍵字的識別碼使用 __identifier 關鍵字,但就樣式而言,強烈建議不要使用。
Windows 執行階段
需求
編譯器選項:/ZW
範例
範例
在下列範例中,會在 C# 中建立名為 template
的類別,並以 DLL 的形式散發。 在使用 類別的 C++/CLI 程式中 template
, __identifier
關鍵字會隱藏標準 C++ 關鍵字的事實 template
。
// identifier_template.cs
// compile with: /target:library
public class template {
public void Run() { }
}
// keyword__identifier.cpp
// compile with: /ZW
#using <identifier_template.dll>
int main() {
__identifier(template)^ pTemplate = ref new __identifier(template)();
pTemplate->Run();
}
Common Language Runtime
備註
__Identifier 關鍵字適用於 /clr
編譯器選項。
需求
編譯器選項:/clr
範例
在下列範例中,會在 C# 中建立名為 template
的類別,並以 DLL 的形式散發。 在使用 類別的 C++/CLI 程式中 template
, __identifier
關鍵字會隱藏標準 C++ 關鍵字的事實 template
。
// identifier_template.cs
// compile with: /target:library
public class template {
public void Run() { }
}
// keyword__identifier.cpp
// compile with: /clr
#using <identifier_template.dll>
int main() {
__identifier(template) ^pTemplate = gcnew __identifier(template)();
pTemplate->Run();
}
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應