Hello, I have been testing out the fstream part of the standard library. I wanted to make a header file, so it is easier to use, so I wrote the file, and a test program to go with it.
Th error I'm getting is:line 7 error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&, ...
It's something similar for every time I make a call to a fstream object
I guess my question is: Can you make a header for fstream? If so, What did I do wrong?
Since I don't think it has to do with the problem, I put up a pastebin for the main code: http://pastebin.com/Cfpi6ELE
Here's the fileIO.h code:
Thank you all for your help. As I am not a master with pointers and references. Am I correct that in the declaration, and usage I would pass the variables with the (&) symbol to pass the memory adress, and when accessing the variables inside the function (e.g. fileRead.open(fileName, ios::in);), I would use the (*) symbol to access what's at memory adress &fileName (So, fileRead.open(*fileName, ios::in);)
That's me trying to understand and rephrase pointers.
As for you BranFlakes, would I call open as open(fileName.c_str(), fileRead, fileWrite); and a personal thanks for spotting those typo's.
So, I might have more problems here, but not for a couple days.
No, not unless fileName is a char**. fileName is a string, so it will be fileRead.open(fileName.c_str(), ios::in);
Besides, no one ever said to pass fileName as a pointer.
We're telling you to pass fileRead and fileWrite by reference, which means changing the function to what vlad wrote above your post.
References are used as if they were normal variables, so no dereference operators are necessary.