What I might suggest, is not to use the line: "using namespace std" since that will bring all thing defined in that namespace into your local scope..
Instead pre-qualify std stuff with the std namespace qualifier.
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
// using namespace std; // leave this commented out
void mygreater(std::ifstream& fin_par);
int main()
{
std::ifstream fin;
fin.open("numfile.dat");
if (fin.fail())
{
std::cout <<"Input file opening failed.\n";
exit (1);
}
mygreater(fin);
fin.close();
return 0;
}
void mygreater(std::ifstream& fin_par)
{
int count, number;
fin_par >> number;
count = 0;
do
{
if (number > count)
{
count = number;
fin_par >> number;
}
else
{
fin_par >> number;
}
} while (! fin_par.eof());
cout << count;
}
The reason for this is that the object 'greater''s name is really std::greater, but when you use the 'using namespace std' clause, you cause 'greater' to resolve to 'std::greater'..
This way you are fine to call your function 'greater' if you like...
Its all about personal choice.. I see that namespace's most usefull purpose is to avoid name pollution, and 'using namespace ????' clauses do the opposite (ie, it pollutes the namespace)..
Cheers..