I\'ve been looking for an answer on websites but couldn\'t find any answer that helped me.
I have a code that uses strings when i tried (like suggested) to add these
Put #include <string>
first.
Avoid using
statements in headers as you potentially bring in all sorts of stuff into many compilation units. using std::string
is perhaps acceptable in a header but using namespace std
certainly isn't as it will cause so much namespace pollution in all compilation units. The std namespace is continuously expanding (look at all the new stuff in C++), so you don't want to have to fix lots of errors when upgrading your compiler.
The include
should come before the using
#include <string>
using namespace std;
//using std::string; <-- Needless