[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
using Directives And enum
From: |
james . p . williams |
Subject: |
using Directives And enum |
Date: |
Sun, 29 Mar 2009 21:34:34 -0700 (PDT) |
User-agent: |
G2/1.0 |
I want two classes to have the same enum list, but I want the list to
be in only one place. I know I can include a common header within the
two class declarations, but wanted to use namespaces instead. The
common header may contain stuff I don't want in the two classes.
Here's my attempt.
namespace Common{
enum Zlorp {A,B,C};
}
class WantsZlorp {
public:
using namespace Common; //errors listed below refer to this line
};
class AlsoWantsZlorp {
public:
using namespace Common;
};
int main(int,char **)
{
WantsZlorp::Zlorp z1=WantsZlorp::A;
AlsoWantsZlorp::Zlorp z2=AlsoWantsZlorp::B;
}
Using g++ 3.4.6, the indicated line gives me the following errors,
among others.
error: expected nested-name-specifier before "namespace"
error: expected unqualified-id before "namespace"
error: expected ';' before "namespace";
error: expected unqualified-id before "namespace"
Apparently, the second and last errors are redundant. In summary, I
thought a using directive introduced into my scope all the names in
the namespace scope. Is there a way to get what I'm after?
Thanks,
Jim
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- using Directives And enum,
james . p . williams <=