작동합니다 : copy(test.begin(), test.end(), sIt);
작동하도록 operator <<
를 오버로드 할 수있는 적절한 방법이 무엇인지연산자 오버로딩 << 다음 코드에서 문자열
using namespace std;
//ostream& operator<< (ostream& out,const string & str)
//{
// out << str.c_str();
// return out;
//}
int _tmain(int argc, _TCHAR* argv[])
{
ofstream file("file.out");
vector<string> test(2);
test[0] = "str1";
test[1] = "str2";
ostream_iterator<string> sIt(file);
copy(test.begin(), test.end(), sIt);
file.close();
return 0;
}
.
무엇이 누락 되었습니까?
편집 : 나는 그냥 ... 바보는
감사합니다 "문자열"헤더를 포함하는 것을 잊었다!
에 대한 cplusplus.com에서 링크를 추가합니다. –