While the contingency is not all that probable, it cannot be totally ruled out that a C# or VB.NET component developer might inadvertently use a C++ keyword as a class name or a public field name. Anyway, the C++ team decided that they had to allow for this probability and gave us the __identifier keyword which allows us to use C++ keywords as identifiers in C++ source code.
See the following C# class library :-
/*
csc /t:library Class1.cs
*/
public class gcnew
{
public gcnew()
{
generic = 25;
}
public int generic;
}
To use it from C++, you can use the __identifier keyword as shown below :-
/*
cl/clr /FUClass1.dll Prog1.cpp
*/
int main()
{
__identifier(gcnew)^ g = gcnew __identifier(gcnew)();
int x = g->__identifier(generic);
return 0;
}