Why is writing using namespace std; in a header file considered bad practice?
Correct answer C. It forces every file that includes the header to import all std names, risking name clashes
A using-directive in a header leaks into every translation unit that includes it, directly or indirectly, and cannot be undone there. This can cause ambiguities when user code defines names such as count, distance or size that also exist in std. In headers, qualify names with std:: or use specific using-declarations inside function bodies.
Answer checked How we write and check questions
Discussion