Enum Issue
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Enum Issue

  1. #1
    Join Date
    Feb 2007
    Posts
    35

    Enum Issue

    Hi Experts

    I am migrating one project from Vc 6.0 to Vc 8.0. I found one compilation Error regarding Enum.

    In Vc 6.0 they have declared an enum in a class and again the same enum they are using in other class with scope resolution and have changed the enum value. It is compiling fine on Vc 6.0 but throwing an error while compiling in Vc 8.0.

    Example code.


    class CTest
    {
    public:
    enum TestEnum {NA=0, First};
    };


    class CTest1
    {
    public:
    enum CTest::TestEnum {Second, Third};

    };


    It is working fine in Vc 6.0 but throwing error in Vc 8.0
    Error is:- error C2911: 'CTest::TestEnum' : cannot be declared or defined in the current scope

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,889

    Re: Enum Issue

    You cannot redefine or append an enum.

    You will need to figure out why the 2nd enum is there. Then somehow 'solve' the error. This could mean deleting the first enum, deleting the 2nd enum. renaming either of the two (or both if that makes sense). or somethign else entirely. without seeing the actual problem it's not possible to give a clear answer as to what's best for you.

    If you were hoping for a compiler "fix". Then sorry, there is none, the VC6 synax is not valid, never was valid, and only compiled in VC6 due to a huge amount of standards compliance issues.

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