ofstream

So im trying to call the ofstream constructor. When i call it with a string like "this" it works but with the string value command[1]
it gives me this error:

no matching function for call to `std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(std::string&, const std::_Ios_Openmode&)'

i guess command[1] isnt the right type but i dont understand these damn error codes they are like hieroglyphics to me

 
ofstream ofs(command[1], ofstream::out);
Last edited on
std::ofstream is really a std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream then it is saying there is no overload for std::string&, const std::_Ios_Openmode&

The overloads are(c++11):
1
2
3
4
5
6
7
8
9
10
11
default (1)	
basic_ofstream();
initialization (2)	
explicit basic_ofstream (const char* filename,
                         ios_base::openmode mode = ios_base::out);
explicit basic_ofstream (const string& filename,
                         ios_base::openmode mode = ios_base::out);
copy (3)	
basic_ofstream (const basic_ofstream&) = delete;
move (4)	
basic_ofstream (basic_ofstream&& x);


There's no point in really telling it it is for out only. Considering it is a ofstream. Try something like: ofstream ofs(command[1]);
Topic archived. No new replies allowed.