[ onako @ 25.04.2010. 13:56 ] @
As a part of the project I'm working on multiple .ps files need be generated. Note the following: Code: outputForGallery( int k) { std::string s; std::stringstream myOut; myOut<<k; s=myOut.str(); std::string fileName="pics/forGallery"; fileName.append(s); fileName.append(".ps"); std::ofstream saveFile(fileName); This means if 0 is passed as a parameter, file with filename forGallery0.ps should be formed(in pics folder). However, I got the following error: Code: error: no matching function for call to ‘std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(std::string&)’ /usr/include/c++/4.4/fstream:623: note: candidates are: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/4.4/fstream:608: note: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char, _Traits = std::char_traits<char>] /usr/include/c++/4.4/iosfwd:84: note: std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(const std::basic_ofstream<char, std::char_traits<char> >&) Any suggestions on how to avoid this, or other ideas to print files with different filenames are very welcome. I understand that std::ofstream saveFile("something.ps"); would work, but I want this to be dynamic. Kind regards, |