Converting an ifstream to an istream
Boy, am I beginning to hate C++, and here's one of the reasons why:
Me (to compiler):
Code:
#include <fstream>
int important_function(std::istream ){
return 0;
}
int main() {
std::ifstream f("dummy_file");
important_function(f);
return 0;
}
Compiler (to me): 'important_function' : cannot convert parameter 1 from 'std::ifstream' to 'std::istream'
Me (to compiler): How about this?
Code:
#include <fstream>
int important_function(std::istream ){
return 0;
}
int main() {
std::ifstream f("dummy_file");
important_function(*(reinterpret_cast<istream *>(f)));
return 0;
}
Compiler (to me): 'important_function' : cannot convert parameter 1 from 'std::istream' to 'std::istream'
I ended up using a reference, which I don't need. I only need the value. Why can't it just copy the damn structure? Is there any way to make it to?
Thank you for your time :-)