Declaration:ifstream ReadFile( ifstream& openInputFile, string& sLine, int chgLine ) (three arguments: openInputFile, sLine, chgLine)
Call: ReadFile( open ); (one argument: open)
You have to pass the same number of arguments and of the same type used on the declaration. (If you want it, you can declare an argument to be optional)
It complies now but im getting some oct code. My Plan was to use the ReadFile func to shorten the length of main.
I dont like the fact that i have to re-declare my paramters but evidently thats just the way life is.
Anyways, I think im going to do this step by step, one FP that does its own individual task, i.e. openFile, readFile, do something with the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ifstream openInputFile()
{
string MyFile,
ifstream inFile;
inFile.open( MyFile.c_str(), ios::in );
// return a pointer is what im looking for.
}
int main()
{
// prompt user for the file
// validate
// use openInputFile to find if userInput matchs the file
}
Keep in mind that local objects go out of scope when the function that created them returns, so if you return a pointer to one and try to use that pointer, you'll cause a segmentation fault.
Example: