problem with enum
I am using Visual C++ .NET Beta 2 ...
I have ported some code where an enumeration from a class library was viewable in the Object Browser.
I can no longer use _value unless I use /Clr:oldcode -- but when I use that I lose the ability to set /Doc which I would like to use to generate XDC files.
Any suggestions?
[323 byte] By [
bxs122] at [2007-12-16]
If I understand correctly, you want to know how to create managed enums using C++/CLI. Please tell me if this is wrong.
To create managed enums in C++/CLI, you would use the following code:
public enum class day
{
Sunday = 0,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
};
With managed enums, you can also change the default underlying type to something other than int:
enum class truth : bool
{
/* The enum can be cast to a bool instead of an int */
Correct = true,
Incorrect = false
};
Note that a behavioural change in VC++2005 causes normal enums to be compiled as managed enums. However, these enums will behave like normal C++ enums (the compile will differentiate between normal and managed enums through the [NativeEnumAttribute]). In old Managed C++, normal enums get cast into "Int32"s.
If you think you are affected by this change, you should consult the topic on C++/CLI enums:
enum class:
http://msdn2.microsoft.com/library/a6cskb49(en-us,vs.80).aspx
A guide on upgrading old Managed C++ topics to C++/CLI is found in this checklist:
Managed Extensions for C++ Syntax Upgrade Checklist
http://msdn2.microsoft.com/library/b23b94s7(en-us,vs.80).aspx