tags:

views:

87

answers:

2
+3  Q: 

Using enumerations

Hello, I can't understand one problem:

Types.hpp:

enum SomeEnum { one, two, three };

First.hpp:

#include "Types.hpp"
class First
{
   public: void someFunc(SomeEnum type) { /* ... */ }
};

Second.hpp:

#include "Types.hpp"
#include "First.hpp"
class Second
{
   public: void Foo()
   {
      First obj;
      obj.someFunc(two); // two is from SomeEnum
   }
};

Thee error:

no matching function for call to ‘First::someFunc(SomeEnum)’
note: candidate is: void First::someFunc(First::SomeEnum)
+1  A: 

I think you just changed that:

no matching function for call to ‘First::someFunc(SomeEnum)’
note: candidate is: void First::someFunc(First::SomeEnum)

wasn't this:

no matching function for call to ‘First::someFunc(SomeEnum)’
note: candidate is: bool First::someFunc(First::SomeEnum)

Anyway, this changes the things. Is the enum declared inside class First ? If so, or if you don't know, just try to call the function, puttung First:: in front of the enum:

obj.someFunc( First::two ); // two is from SomeEnum
              ^^^^^^^
Kiril Kirov
+1  A: 

I might bt totally wrong in interpreting the complier error but

note: candidate is: void First::someFunc(First::SomeEnum)

Leads me to believe that you declared SomeEnum inside First's definition

class First
{
    SomeEnum {one, two, three};
}
Nat