I have overload const
and non-const
functions in c++ structure. Then, I have run the program and I wondered, it's working fine without ambiguous error.
#include <iostream>
struct St
{
int f() const
{
return 1;
}
int f()
{
return 2;
}
} s;
int main()
{
int ret = s.f();
std::cout<<ret<<std::endl;
return 0;
}
So, I just want to know, Why doesn't compiler give an ambiguous error?
Aucun commentaire:
Enregistrer un commentaire