his_dudeness his_dudeness - 1 year ago 143
C++ Question

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


#include <string>


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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download