Freaky_Chris and mrboolf, yeah, sorry it was my mistake when I wrote the thread. For some reason I didn't just copy and paste. Line 38 should be
as Freaky_Chris pointed out.
if u cannot pass by reference,
why do you need to pass an ifstream object.Just declare an instance of ifstream again and initialize that with the same file.
foo.open ("whatever be the filename.txt", ifstream::in);
and use it
The problem with this approach is that I plan to use the function with more than one file.