CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2013

    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?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Hanover Germany

    Re: enum versus private enum

    Wrong Forum!
    This Forum is for
    Visual C++ Programming
    Ask questions about Windows programming with Visual C++ and help others by answering their questions.
    and not for a managed C++/CLI one!
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2013

    Re: enum versus private enum

    I'm going to move it there. I hope you'll answer me there.

  4. #4
    Join Date
    Mar 2013

    Re: enum versus private enum

    Well I guess not.
    I'm not looking for hall monitors, I'm looking for help and it appears I'm in the wrong place.

    Nice plaque - it swept me off my feet. Bye.

  5. #5
    Join Date
    Feb 2003
    Iasi - Romania

    Re: enum versus private enum

    Well, you are now in the right place: "Managed C++ and C++/CLI".
    Not because some evil "hall monitors" just want to move your posts, but to give you a better chance to get an answer.

    [ Moved thread ]
    "When in Rome, do as Romans do."
    My latest articles: http://codexpert.ro/blog/author/ovidiu-cucu/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.