Tuesday, October 20, 2015

Name must be a namespace name error in Visual C++

Following error was observed in Microsoft Visual C++ 2010 edition while using std namespace.

Error: IntelliSense: name must be a namespace name

Problem code:

using namespace std;

Solution:

#include <iostream>
using namespace std;

This Visual C++ IntelliSense error occurs when you write using namespace std before including a standard header that defines the std namespace, so the compiler has no namespace to refer to.

Adding the relevant include, such as iostream, before the using directive resolves it. Order matters: headers must be included so the names they declare exist.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.