So I was playing around a bit with file ofstream and ifstream and got stuck into a compiler problem that I just simply don't know what it means...
Let's start.
I have the following class:
class FS{
public:
string name;
long long int size;
long long int freeBlocks;
long long int usedBlocks = 0;
int blocksize = 128;
vector<FS_File> file_list;
char * ptr; //This is a malloc pointer
void saveTo(ofstream& of);
void openFrom(ifstream& inf);
};
The problem occurs in the saveTo() function:
void FS::saveTo(ofstream& of){
of.write(&name, sizeof(name));
of.write(&size, sizeof(size));
of.write(&freeBlocks, sizeof(freeBlocks));
of.write(&usedBlocks, sizeof(usedBlocks));
of.write(&blocksize, sizeof(blocksize));
of.write(&file_list, sizeof(file_list));
of.write((char *)&ptr, sizeof(ptr));
}
The compiler gives me the next error:
functions.cpp In member function 'void FS::saveTo(std::ofstream&)':
[Error] no matching function for call to 'std::basic_ofstream<char>::write(std::string*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ofstream<char>::write(long long int*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ofstream<char>::write(long long int*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ofstream<char>::write(long long int*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ofstream<char>::write(int*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ofstream<char>::write(std::vector<FS_File>*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ifstream<char>::read(std::string*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ifstream<char>::read(long long int*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ifstream<char>::read(long long int*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ifstream<char>::read(long long int*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ifstream<char>::read(int*, long long unsigned int)'
[Error] no matching function for call to 'std::basic_ifstream<char>::read(std::vector<FS_File>*, long long unsigned int)'
Whenever I try to call the next code:
ofstream outfile;
string filename = curFS.name + ".dat";
outfile.open(filename, ios::binary | ios::out);
curFS.save(outfile);
outfile.close();
I've tried a few things, but nothing has worked...
What does the compiler error means? How can I solve it?
Aucun commentaire:
Enregistrer un commentaire