The only problem is the functions:
void a(int &val)
and
void a(int val)
The compiler will generate the following errors:
Compilation error time: 0 memory: 3140 signal:0
prog.cpp: In function 'int main()':
prog.cpp:28:8: error: call of overloaded 'a(int&)' is ambiguous
a(iTmp);
^
Since it cannot distinguish between both, if you delete one of them, compilation succeeds
See an example:
#include <iostream>
using namespace std;
void a(int val)
{
cout<<val;
}
void a(int *val)
{
cout<<val;
}
void a(double val)
{
cout<<val;
}
int main() {
int iTmp = 0;
int *pTmp = 0;
double dTmp = 0.0;
a(iTmp);
a(iTmp);
a(pTmp);
a(dTmp);
return 0;
}
See working example:
http://ideone.com/WRZUoW
source
share