In Visual C++ .net when I try to compile the code I get the error C2664 'write' cannot convert parameter 1 from 'std;;ofstream' to 'std;;ofstream' (i used semicolons instead of colons so the forum doesn't convert it to emoticons)
Below is an example of the code it doesn't like. What am I doing wrong? Is there a better way to pass file output to a modularized function yet open the file for output inside main()?
#include <iostream>
#include <fstream>
using namespace std;
void write(ofstream);
void main()
{
ofstream outfile;
outfile.open("C:\\blah.txt");
write(outfile);
}
void write(ofstream outfile)
{
outfile << "hi";
}
Below is an example of the code it doesn't like. What am I doing wrong? Is there a better way to pass file output to a modularized function yet open the file for output inside main()?
#include <iostream>
#include <fstream>
using namespace std;
void write(ofstream);
void main()
{
ofstream outfile;
outfile.open("C:\\blah.txt");
write(outfile);
}
void write(ofstream outfile)
{
outfile << "hi";
}