Passing ofstream object from main program to a class
<p>Here is what I am trying to do:<br />
1) Open an ofstream object in my main body.  I can do this no problem.<br />
2) Associate this object with a filename.  No problem.<br />
3) Pass this object to a class and send output within this class.  I can't do this.<br />
Here is my code.  I would appreciate any help.  Thanks!</p>

<pre><code>#include &lt;fstream&gt;
#include &lt;iostream&gt;
using namespace std;

typedef class Object
{
public:
 Object(ofstream filein);
} Object;

Object::Object(ofstream filein)
{
 filein &lt;&lt; "Success";
}

int main (int argc, char * const argv[])
{
 ofstream outfile;
 outfile.open("../../out.txt");

 Object o(outfile); 

 outfile.close();
 return 0;
}
</code></pre>
