Discussion Board

Results 1 to 5 of 5

Hybrid View

  1. #1
    Regular Contributor vinp's Avatar
    Join Date
    Aug 2010
    Posts
    347
    Hello,

    This is not specifically a Symbian C++ query, but is related to C++ in general.

    I ran into the following error in my code:

    illegal name overloading

    And what caused this was the repeated use of the same value, none, in two different enum declarations:

    Code:
    enum A
    {
    ...
    none
    };
    
    enum B
    {
    none,
    ....
    }
    I would appreciate your thoughts.

    TIA
    Vin

  2. #2
    Nokia Developer Champion not_dying's Avatar
    Join Date
    Feb 2009
    Location
    India
    Posts
    813
    I think it will depend on the Location where you are trying to define these two Enums i.e. Scope. If you are trying to define them in a single class then they will not work. But if tried in two different classes (obviously in the same application) then they should work.

  3. #3
    Regular Contributor vinp's Avatar
    Join Date
    Aug 2010
    Posts
    347
    I am declaring these two enumerations as outside of any class, and using variables of their type in the same class.

    For example

    Code:
    enum A
    {
    ....
    none
    };
    
    enum B
    {
    none,
    ....
    };
    
    class C
    {
    A a;
    B b;
    };
    But I am getting the error in the header file itself, where the enums are declared outside any class scope.

  4. #4
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    An enumeration is not a container, it does not provide a scope. Thus "none" is declared twice, and that is the problem.

    It is good to know and good to remember. There was a thread where someone was developing a code for years, and it worked on everything up to S60 3rd FP1 (including S60 2nd editions too). Then S60 3rd FP2 came, and introduced some enumerations in the middle of the camera engine, clashing with his own ones. That was a slightly mystical one to find out, but it was exactly the same thing you are depicting here.

  5. #5
    Regular Contributor vinp's Avatar
    Join Date
    Aug 2010
    Posts
    347
    Thanks for the info.

Similar Threads

  1. illegal function overloading
    By iron94 in forum Symbian C++
    Replies: 2
    Last Post: 2010-04-06, 09:42
  2. Overloading new opearator
    By Shilpa13 in forum Symbian C++
    Replies: 3
    Last Post: 2009-05-16, 09:18
  3. Replies: 3
    Last Post: 2007-11-06, 14:39
  4. overloading delete operator
    By mihirg in forum Symbian C++
    Replies: 3
    Last Post: 2007-10-09, 09:02
  5. Overloading of addCommand()
    By namrata in forum Mobile Java General
    Replies: 8
    Last Post: 2007-02-21, 12:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved