Here is what I am trying to do:
1) Open the outstream object in my main body. I can do it without a problem.
2) Associate this object with the file name. No problems.
3) Pass this object to the class and send the output in this class. I can not do it. Here is my code. I would appreciate any help. Thanks!
#include <fstream> #include <iostream> using namespace std; typedef class Object { public: Object(ofstream filein); } Object; Object::Object(ofstream filein) { filein << "Success"; } int main (int argc, char * const argv[]) { ofstream outfile; outfile.open("../../out.txt"); Object o(outfile); outfile.close(); return 0; }
source share