Reputation: 459
I have a function that operates on an std::ifstream
:
#include <fstream>
void handle(std::ifstream file) {
// Do things
}
int main() {
std::ifstream file("x.txt");
handle(file);
}
This code gives me this error.
However, if I make handle
's single parameter a reference (void handle(std::ifstream& file
), the code compiles without warnings.
Why?
Upvotes: 0
Views: 23