__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();
}

另請參閱

適用於.NET 和 UWP 的元件延伸模組
適用於.NET 和 UWP 的元件延伸模組