Pass the link to the stream:
void first() {
std::ifstream in("in.txt");
std::ofstream out("out.txt");
second(in, out);
out.close();
in.close();
}
void second(std::istream& in, std::ostream& out) {
}
You can #include <iosfwd>get ads ahead for istreamand ostream, if you need to declare secondin the header and do not want the files containing this header to be contaminated with unnecessary definitions.
const, ( ) () .