Multiple Namespaces.

closed account (zb0S216C)
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.
Namespaces are additive - so you will end up with one namespace with two variables in it.
s it valid to define two namespaces with the same name with different contents?
Yes it is
closed account (zb0S216C)
Thanks coder777.
Last edited on
Topic archived. No new replies allowed.