Is this a good way to use a namespace?
Code:#include <iostream> namespace Hw { void hello(); } void Hw::hello() { using namespace std; cout << "Hello, world.\n"; } int main() { Hw::hello();}
Is this a good way to use a namespace?
Code:#include <iostream> namespace Hw { void hello(); } void Hw::hello() { using namespace std; cout << "Hello, world.\n"; } int main() { Hw::hello();}
I don't see a problem with it. Real world examples are more complex and have different criteria for how you want to do things. I prefer to always explicitly specify the std namespace, but putting the using directive inside the function is almost always fine.