"cpp" <cp*@on.the.net> wrote in message
news:Xn*************************@24.24.2.165...
When I create an instance of ofstream, what is the name of the member
variable that holds the filename?
There is none.
For example:
ofstream ofs("Output.txt");
cout << ofs.WhatIsThePathVariable;
If there isn't a public member variable I can use, then is there at least
a function that displays the filename?
No again.
Use a little imagination. Since you opened the file with a file name you
must also be capable of storing that file name somewhere. For instance you
could derive a class from ofstream that stores the filename
class ofstream_with_filename : public ofstream
{
public:
void open(const char* fn)
{
ofstream::open(fn);
filename = fn;
}
string get_filename() const { return filename; }
private:
string filename;
};
I hope that gives you the idea, real code would be a little more
sophisticated than the above.
john