Using ofstream in private of a class-errors
Hi!
Trying to use ofstream object like that:
Code:
class X
{
ofstream FileHandle;
int f();
};
int X::f()
{
FileHandle.open("c:\1.txt",ios::binary);
return 0;
}
Now, this produces errors. Anyone has ANY idea why I can't use ofstream there? I read that I should put "static" before "ofstream" but it didn't work. I tried using std::ofstream, too, but it too didn't work. I tried using pointer:
ofstream *FileHandle;
....
FileHandle = new ofstream;
FileHandle.open(...);
But this didn't work also.
I forgot to mention:
There is no error if I don't use any member functions of the ofstream class... i.e. if I do not use the FileHandle.open() function.
The errror comes when I try to use the open() function. The error is:
Quote:
error LNK2001: unresolved external symbol "private: static class ofstream waveIn::FileHandle" (?FileHandle@waveIn@@0Vofstream@@A)