In article < .com>,
"Jamiil" <> wrote:
> Hey folks!
> I have declared an enum type inside a name space
> namespace jme{
> enum hero_t{zorro, batmant, cat_woman, other};
> class MyClass{
> private: hero_t my_hero
> ....
> };
> }
>
> But the compiler complain saying:
> somefile.hpp:26: error: conflicting declaration 'zorro'
> somefile.hpp:26: error: 'jme::zorro' has a previous declaration as
> `jme::hero_t
> ...
>
> and the same error is produced for all the other members of hero_t?
>
> What am I doing wrogn?
The problems I found in your code:
1) '....' is a parse error. I'm thinking it should be commented out.
2) 'hero_t my_hero' didn't have a semicolon after it, I fixed that.
The below compiles fine.
namespace jme {
enum hero_t {zorro, batmant, cat_woman, other};
class MyClass {
private:
hero_t my_hero;
//...
};
}
Now, what can I do to the above code to caluse the kind of errors you
are talking about? How about...
namespace jme {
enum hero_t {zorro, batmant, cat_woman, other};
enum hero_t {zorro, batmant, cat_woman, other};
}
The above seems to do something much like what you are complaining
about. I'd say your problem is multiple declarations in the same source
file.
Read up on include guards.
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
|