I am learning the STL and have some questions.
1. In the first cout, why doesn't c print out?Code:#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> vec;
vec.push_back("test");
string s(vec[0]); //turn vec[0] into a string named s
std::string c( s.size(), char() );
cout << c << endl;
copy( s.begin(), s.end(), c.begin() );
cout << c << endl;
return 0;
}
2. If I eliminate std::string and define string c above, this doesn't work. I get an error: no match for call to (std::string) (size_t, char). What is it that std::string is doing in this case?