Hi friends, trying to pass an ifstream to a function expecting an ostream...Should this be a problem?

ifstream fleetin;
fleetin.open (filename);

read(fleetin);

//Error....
: cannot convert parameter 1 from 'std::ifstream' to 'std::ostream &'

My parameter is declared as ostream&, or maybe i should just remove the '&', but thought it's a good practice to pass reference params

Recommended Answers

All 2 Replies

oops! my bad, should be 'istream', not ostream...

>>or maybe i should just remove the '&', but thought it's a good practice to pass reference params

Don't remove the & because open streams must be passed by reference.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.