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
_______________________________________________
help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus