for my assignment I am building a heap, the data for the heap is coming from a file. One of the functions is to get the data, but I am having trouble understanding the ifstream read() function and am getting quite a nasty error because of it this is what I have:
template<class T, class P>
void get_list(vector<T>& v, const char* file_loc, P func) {
T data;
ifstream inFile;
inFile.open("file_loc");
if (!inFile) {
cerr << "Error - unable to open input file\n";
exit(1);
}
inFile.read( &data, sizeof(T));
while (inFile) {
inFile.read( &data, sizeof(T));
insert(v,data,func);
}
inFile.close();
}
the error I am receiving is:
prog7.h:53: error: no matching function for call to
‘std::basic_ifstream<char, std::char_traits<char> >::read(int*, long unsigned int)’
/usr/include/c++/4.3/istream:468: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,_Traits>::read(_CharT*, std::streamsize)
[with _CharT = char, _Traits = std::char_traits<char>]
any help would be much appreciated!