Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > namespace and enum?

Reply
Thread Tools

namespace and enum?

 
 
Jamiil
Guest
Posts: n/a
 
      02-04-2006
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?

TIA

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      02-04-2006
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
> ....
> };
> }


I counted 7 lines total here (including the ellipsis).

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


Which one is line 26 and what happened with the other nineteen?

> ...
>
> and the same error is produced for all the other members of hero_t?


Is that a question?

>
> What am I doing wrogn?


You're not posting the code you're getting the error in. Read
the FAQ section 5.

V
--
Please remove capital As from my address when replying by mail


 
Reply With Quote
 
 
 
 
Jamiil
Guest
Posts: n/a
 
      02-04-2006
Hello Victor, thanks for your prompt response.
You are absolutely right; I am not posting the source code, just a
sample code.
It is company policy not to disclose any parts of the programs, but I
can provide you with an example that demonstrates the error. But, at
the same time, who in their right mind would want 828,675 lines of code
in the bandwidth. I could use a snip, which is something the company
does not want, but the snip will show the same data; all I have to do
is change the names of things.
Thanks Victor for all the help, "surely it would be very difficult to
solve problems without the help of programmers like yourself".


Victor Bazarov wrote:
> 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
> > ....
> > };
> > }

>
> I counted 7 lines total here (including the ellipsis).
>
> >
> > 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

>
> Which one is line 26 and what happened with the other nineteen?
>
> > ...
> >
> > and the same error is produced for all the other members of hero_t?

>
> Is that a question?
>
> >
> > What am I doing wrogn?

>
> You're not posting the code you're getting the error in. Read
> the FAQ section 5.
>
> V
> --
> Please remove capital As from my address when replying by mail


 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      02-04-2006
Jamiil wrote:
> ...


Don't top post.

> Victor Bazarov wrote:
>> 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
>>> ....
>>> };
>>> }

>>
>> I counted 7 lines total here (including the ellipsis).
>>
>>>
>>> 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

>>
>> Which one is line 26 and what happened with the other nineteen?
>>
>>> ...
>>>
>>> and the same error is produced for all the other members of hero_t?

>>
>> Is that a question?
>>
>>>
>>> What am I doing wrogn?

>>
>> You're not posting the code you're getting the error in. Read
>> the FAQ section 5.

>
> Hello Victor, thanks for your prompt response.
> You are absolutely right; I am not posting the source code, just a
> sample code.


No, it's not even sample code. Sample code would actually be suitable
to put in a file and pass to the compiler to demonstrate the error you
were asking about.

> It is company policy not to disclose any parts of the programs, but I
> can provide you with an example that demonstrates the error.


What stopped you the first time?

> But, at
> the same time, who in their right mind would want 828,675 lines of
> code in the bandwidth.


Nobody. That's why the FAQ says what it says. Did you bother to read
it, as I suggested?

> I could use a snip, which is something the
> company does not want, but the snip will show the same data; all I
> have to do is change the names of things.


It is up to you to remove all irrelevant pieces. Do that. Perhaps
while doing it you will discover what is wrong with your program...

V
--
Please remove capital As from my address when replying by mail


 
Reply With Quote
 
Daniel T.
Guest
Posts: n/a
 
      02-05-2006
In article <(E-Mail Removed) .com>,
"Jamiil" <(E-Mail Removed)> 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.
 
Reply With Quote
 
Luke Meyers
Guest
Posts: n/a
 
      02-05-2006
Jamiil wrote:
> You are absolutely right; I am not posting the source code, just a
> sample code.
> It is company policy not to disclose any parts of the programs,


Sigh... all together now... "post the smallest complete example that
demonstrates the problem."

> but I
> can provide you with an example that demonstrates the error.


Why didn't you?

> But, at
> the same time, who in their right mind would want 828,675 lines of code
> in the bandwidth.


No one, obviously. Who in their right mind would think it would be
necessary? Post the relevant code, not every line of code you have
access to. Nothing you're experiencing is complex enough to require
nearly that much code to explain it.

Incidentally, leaking a precise SLOC number like this is probably just
the sort of technical information your company would rather not see
floating around the internet.

> I could use a snip, which is something the company
> does not want, but the snip will show the same data; all I have to do
> is change the names of things.


It should be trivial to post a sufficiently simplified and abstract
example of the problem that no sane employer would object to. Perhaps
you're being overly literal with regard to company policy? Policies
like this are always conservatively worded, sometimes to excess (much
like a EULA) to cover the org's ass. Your job is to interpret the rule
in such a way that you can respect it and follow its intent, but not so
narrowly that it winds up inhibiting your job (contrary to its
presumable intent).

Luke

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR CS0234: The type or namespace name 'DataAccessHelper' does not exist in the namespace 'BCC' (are you missing an assembly reference?) li.eddie@gmail.com ASP .Net 0 01-06-2006 11:31 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Reaching into the default namespace when using another namespace. Jason Heyes C++ 1 11-19-2004 02:36 AM
Namespace: Is it a scope or a namespace? Anonymous C++ 3 08-18-2003 01:31 PM
Help:Why can't I use namespace System.Web? It is said that this namespace doesn't exist. But it should exist. ASP .Net 1 07-29-2003 04:31 PM



Advertisments