My question is simple, why a class and its nested class cannot have same name, but namespaces can?
for example:
class Test {
class Test {};
};
is invalid, but
namespace Test {
namespace Test {}
}
is valid
My question is simple, why a class and its nested class cannot have same name, but namespaces can?
for example:
class Test {
class Test {};
};
is invalid, but
namespace Test {
namespace Test {}
}
is valid
Class X
already has a member named X
, referring to itself. This is known as an injected class name. It's then invalid to add another member with the same name.