enum versus private enum
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: enum versus private enum

  1. #1
    Join Date
    Mar 2013
    Posts
    5

    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
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605

    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
    Posts
    5

    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
    Posts
    5

    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
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,059

    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 ]
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: 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

This is a CodeGuru survey question.


Featured


HTML5 Development Center