I have a function in a .h file designed to save some information to a file, but I get this error:
on this line:Code:error: no matching function for call to `std::basic_fstream<char, std::char_traits<char> >::basic_fstream(std::string&, std::_Ios_Openmode)'
This is the full code of the function as well as the includes:Code:fstream fbin(filename, ios::binary | ios::in | ios::out);
I have no idea why I am getting this error, since the line it is pointing to is fairly standard, I think.Code:#include <fstream> #include <iostream> using namespace std; ... void plant::writetofile(int pnum, string filename){ fstream fbin(filename, ios::binary | ios::in | ios::out); if(!fbin){ cout << "Error opening fbin"; } int recsize = sizeof(int) + (sizeof(int) + sizeof(int) + sizeof(int))*2 + sizeof(string); fbin.seekp(pnum * recsize); fbin.write(reinterpret_cast<char*>(&name), sizeof(string)); fbin.write(reinterpret_cast<char*>(waterd.getm()), sizeof(int)); fbin.write(reinterpret_cast<char*>(waterd.getd()), sizeof(int)); fbin.write(reinterpret_cast<char*>(waterd.gety()), sizeof(int)); fbin.write(reinterpret_cast<char*>(aquired.getm()), sizeof(int)); fbin.write(reinterpret_cast<char*>(aquired.getd()), sizeof(int)); fbin.write(reinterpret_cast<char*>(aquired.gety()), sizeof(int)); fbin.write(reinterpret_cast<char*>(&size), sizeof(int)); fbin.close(); return; }
Any idea?
Thanks!



LinkBack URL
About LinkBacks



