Multiple Namespaces.
Jan 29, 2011 at 4:19pm Jan 29, 2011 at 4:19pm UTC
I've got 2 namespaces with the same name. They both have one variable which is named differently, for example:
1 2 3 4 5 6 7 8 9
namespace NamespaceOne
{
int One( 0 );
}
namespace NamespaceOne
{
int Two( 0 );
}
In main( ), I call both variables and assign new values to them, like this:
1 2 3 4 5 6 7
int main( )
{
NamespaceOne::One = 9;
NamespaceOne::Two = 5;
return 0;
}
This compiles with no warnings or errors. Here's my question: Is it valid to define two namespaces with the same name with different contents? I'm doing this because my library is getting quite large and I need to divide my namespace into multiple headers.
Jan 29, 2011 at 4:24pm Jan 29, 2011 at 4:24pm UTC
Namespaces are additive - so you will end up with one namespace with two variables in it.
Jan 29, 2011 at 4:26pm Jan 29, 2011 at 4:26pm UTC
s it valid to define two namespaces with the same name with different contents?
Yes it is
Jan 29, 2011 at 4:41pm Jan 29, 2011 at 4:41pm UTC
Thanks coder777.
Last edited on Jan 29, 2011 at 4:41pm Jan 29, 2011 at 4:41pm UTC
Topic archived. No new replies allowed.