his_dudeness his_dudeness - 2 months ago 14
C++ Question

C++ #include <string> vs using std::string

Does

#include <string>


and

using std::string;


has same meaning? If yes why do we have a separate #include for string. If you are going to tell me that string is so popular that we got a new header, using std::string has same easyness of typing IMHO.

I would appreciate if you can clarify.

P.S. There are similar questions in SO, but they compare using namespace std to using std::string and don't answer my question.

Answer

No, they're not the same. You can add a using std::string declaration, but you still need to #include <string>.