If <string> provides the C++ standard string classes and templates, why is it unnecessary to include in the header of the source code? ..or is it?
Just like in this example:
This happens because <string> is included in either <iostream> or <sstream>. However you cannot be sure it will be, so it's better always to specify what you're including.
What are you talking about? The language is C++ so it would make sense to use C++ standard libraries, not C. Do you have any reasons to say something like this?
Packetpirate, I'm sorry, but we need you to shut up, because this is bad advice that could lead to a lot of problems. <string> is not deprecated, in fact if anything C strings ought to be deprecated. You probably meant <string.h> but there's a huge difference between <string> and <string.h>.
This is the second time you've made this mistake and I've corrected you.
using namespace std; pollutes the global namespace. That is it drags every symbol from the included header into the global arena.
This can make it hard to tell which class or function you are calling and there are a number of subtle errors that can occur like this.
A better way is to either prefix your std symbols with std:: or you could also import only the sympols you use into the global space:
1 2 3 4 5 6 7 8
#include <string>
#include <vector>
using std::string;
using std::vector;
vector<string> svec;
What you must never do is use 'using namespace' or even 'using std::string' in any header files. They should never introduce symbols into the global namespace from the standard libraries (or any other library for that matter).
However in small example programs you can get away with 'using namespace std;' But I personally feel its best to keep consistant habits.