I got a problem with function overloading, probably very stupid and simple, but cant come up with the solution. I defined 2 overloaded functions:
void pp(int) {cout << "1";}
void pp(int&) {cout << "2";}
and later im trying to call them. Calling first one is easy, for example pp(1); Temporary object cant be assigned to non-const reference, so there is no ambguity. But what should I write to call function pp(int&)? I have really no idea. A compiler let for such overloading so I guess there is a way to call both functions. Otherwise it would be pointless to let for such overloading.
Another similar problem looks like follows:
void p(const int) {cout << "1";}
void p(const int&) {cout << "2";}
Compiler let for such overloading, but I have no idea how to call any function without ambiguity. Any clues?
EDIT: This is just an example to think about it, not to use that in real program or something. The code presented here is obviously ugly and only shows some kind of problem.
The main conclusion should be that its the programmer who should take care of ambiguity even if a compiler lets for some overloadings.