fstream& fileReading(const string& signalFile, const string& backgroundFile){
ofstream fileName;
fileName.open(signalFile, ios::in | ios::binary);
//does more stuff here
return fileName;
}
I receive the following error message:
non-const lvalue reference to type 'fstream' cannot bind to a value of unrelated type 'ofstream'.
I am not sure what it means or why I am receiving it.
I have a feeling it has to do with the declaration of the fstream and the ofstream.
When i change the return type to ofstream, I receive a message which states: Reference to stack memory associated with local Variable 'fileName' returned.
I would like a little help understanding what all of this means and how I can refactor the function/method to return a file i would create and write to.
Any help would be greatly appreciated. beginner in c++ having to learn the language on the fly.