use a std::ofstream as function parameter

Hi,

Is there any easy way to use a std::ofstream as parameter of a function?
I would like to be able to write the function:
1
2
3
4
5
6
7
8
int writeInStream(std::ofstream outputFile, std::string txt_to_write) {
	if (!outputFile){ 
		if (openStream(outputFile)==0) // Other fct with the same problem
		return 1; // If stream can't be openend 
	}
	outputFile << txt_to_write << std::endl;
	return 0;
}


Thank you in advance,

Sky
Last edited on
Again, stream are not copyable.
Pass it by reference.
Topic archived. No new replies allowed.