I have the following codeCode://illustrates overloading functions #include <iostream> using namespace std; class rational{ private: long a, q; enum { BIG = 100}; public: rational(int n = 0) : a(n), q(1) {} rational(int i, int j) : a(i), q(j) {} rational(double r) : a(static_cast<long> (r * BIG) ), q(BIG) {} void print() const { cout << a << "/" << q; } operator double() { return static_cast<double>(a) / q; } }; //functions inline int greater(int i, int j){ return ( i > j ? i : j); } inline double greater(double x, double y){ return (x > y ? x : y); } inline rational greater(rational w, rational z){ return (w > z ? w : z); } int main(void){ int i = 10, j = 5; float x = 7.0; double y = 14.5; rational w(10), z(3.5), zmax; cout <<"\ngreater(" << i << "," << j << ") = " << greater(i,j); cout <<"\ngreater(" << x << "," << y << ") = " << greater(x,y); cout <<"\ngreater(" << i << ","; z.print(); cout <<") = " << greater(static_cast<rational>(i), z); zmax = greater(w,z); cout <<"\ngreater("; w.print(); cout << ", "; z.print(); cout << ") = "; zmax.print(); cout << endl; return 0; }

and getting the following errors.

Seems to be saying I can't call the greater function? Just learing about function overloading so any help would be appreciated.Code:$ g++ rational.cpp -o rational rational.cpp: In function ‘int main()’: rational.cpp:43:52: error: reference to ‘greater’ is ambiguous rational.cpp:32:17: error: candidates are: rational greater(rational, rational) rational.cpp:28:15: error: double greater(double, double) rational.cpp:24:12: error: int greater(int, int) In file included from /usr/include/c++/4.7/string:50:0, from /usr/include/c++/4.7/bits/locale_classes.h:42, from /usr/include/c++/4.7/bits/ios_base.h:43, from /usr/include/c++/4.7/ios:43, from /usr/include/c++/4.7/ostream:40, from /usr/include/c++/4.7/iostream:40, from rational.cpp:2: /usr/include/c++/4.7/bits/stl_function.h:224:12: error: template<class _Tp> struct std::greater rational.cpp:44:52: error: reference to ‘greater’ is ambiguous rational.cpp:32:17: error: candidates are: rational greater(rational, rational) rational.cpp:28:15: error: double greater(double, double) rational.cpp:24:12: error: int greater(int, int) In file included from /usr/include/c++/4.7/string:50:0, from /usr/include/c++/4.7/bits/locale_classes.h:42, from /usr/include/c++/4.7/bits/ios_base.h:43, from /usr/include/c++/4.7/ios:43, from /usr/include/c++/4.7/ostream:40, from /usr/include/c++/4.7/iostream:40, from rational.cpp:2: /usr/include/c++/4.7/bits/stl_function.h:224:12: error: template<class _Tp> struct std::greater rational.cpp:47:19: error: reference to ‘greater’ is ambiguous rational.cpp:32:17: error: candidates are: rational greater(rational, rational) rational.cpp:28:15: error: double greater(double, double) rational.cpp:24:12: error: int greater(int, int) In file included from /usr/include/c++/4.7/string:50:0, from /usr/include/c++/4.7/bits/locale_classes.h:42, from /usr/include/c++/4.7/bits/ios_base.h:43, from /usr/include/c++/4.7/ios:43, from /usr/include/c++/4.7/ostream:40, from /usr/include/c++/4.7/iostream:40, from rational.cpp:2: /usr/include/c++/4.7/bits/stl_function.h:224:12: error: template<class _Tp> struct std::greater rational.cpp:48:9: error: reference to ‘greater’ is ambiguous rational.cpp:32:17: error: candidates are: rational greater(rational, rational) rational.cpp:28:15: error: double greater(double, double) rational.cpp:24:12: error: int greater(int, int) In file included from /usr/include/c++/4.7/string:50:0, from /usr/include/c++/4.7/bits/locale_classes.h:42, from /usr/include/c++/4.7/bits/ios_base.h:43, from /usr/include/c++/4.7/ios:43, from /usr/include/c++/4.7/ostream:40, from /usr/include/c++/4.7/iostream:40, from rational.cpp:2: /usr/include/c++/4.7/bits/stl_function.h:224:12: error: template<class _Tp> struct std::greater