so i was trying to override the function max and i ran into lots of errors
> call of overloaded 'max(int&, int&)' is ambiguous
> /usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]
max(const _Tp& __a, const _Tp& __b)
>
> In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
from /usr/include/c++/7/ios:40,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from prog.cpp:1:
my code :
#include<iostream>
using namespace std;
template <typename T>
T max(T a, T b)
{
return a > b?a:b;
}
int main()
{
cout<< max(5,4);
return 0;
}
there a way to override builtin function or predefined functions?
even if i declare
int a(5),b(4);
cout<<max(a,b);
its giving me errors