hi guys, i'm having a bit of a prolem with C++, i've been programming c# for quite a while now, so i am not a novice lol.
problem -- i've created the following ofstream in my main method:
ofstream out1("array1.txt");
however later on in the code i call
out1 << arrayStorage1;
which i have overloaded the operators as.....(in my ArrayIntStorage class)
ostream& operator<< (ostream &out, ArrayIntStorage &ais)
{
ais.write();
return out;
}
and my write method looks like this:
void ArrayIntStorage::write(char fileName[])
{
ofstream out(fileName);
for(int i = 0; i< arrayLength; i++)
{
out << arrayNoSort[i] << endl;
}
out.close();
}
my problem is that i don't want to hardcode the filename ("array1.txt") as i'll need to use this again for create other files, eg; array2.txt and so on, i was wondering if there is a way to get the name of ofstream(*filename*) (in the main method) and use that to specify the filename when i come to write it.
thanks in advance
ryan