I have a code snippet:
namespace Work {
void catch_mouse();
}
namespace Tom {
using namespace Work;
void catch_mouse();
}
int main() {
Tom::catch_mouse();
}
The above code works and calls Tom::catch_mouse();
But the same code with using declaration produces an error.
namespace Work {
void catch_mouse();
}
namespace Tom {
using Work::catch_mouse;
void catch_mouse(); // gives an error; conflicting declaration of catch_mouse
}
int main() {
Tom::catch_mouse();
}
As I understand, both using namespace Work and using Work::catch_mouse brings the declaration into scope then why the first one compiles and the second one produces error?