class C {
using namespace std; // error
};
namespace N {
using namespace std; // ok
}
int main () {
using namespace std; // ok
}
Edi
Because the C++ standard explicitly forbids it. From C++03 §7.3.4 [namespace.udir]:
using-directive:
using namespace ::opt nested-name-specifieropt namespace-name ;
A using-directive shall not appear in class scope, but may appear in namespace scope or in block scope. [Note: when looking up a namespace-name in a using-directive, only namespace names are considered, see 3.4.6. ]
Why does the C++ standard forbid it? I don't know, ask a member of the ISO committee that approved the language standard.