-
March 13th, 2013, 03:10 PM
#1
enum versus private enum
The following code works in VC++ 2010 but generates numerous errors in VC++ 2012:
#include "stdafx.h"
using namespace System;
enum class Months{January = 1, February, March, April };
int main(array<System::String ^> ^args)
{
Months month;
int value;
month = Months::January;
value = safe_cast<int>(month);
Console::WriteLine(L"Month is {0} and the value is {1}.", month, value);
return 0;
}
In order to compile in VC++ 2012, the code must be changed to:
private enum class Months{January = 1, February, March, April };
My question is why?
Is VC++ so chaotic that code from one version won't compile in another version? Doesn't that defy the idea of portable code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|