S
SuperBald
Hello, I tried two functions as blow. The program is compiled successfully in g++ 4.4.1. I expect there will be a compilation error. Any hints? Thanks.
----------------------
#include <iostream>
using namespace std;
void f(int i)
{
cout << "No ref" << endl;
int k = i;
}
void f(int & i)
{
cout << "With ref" << endl;
int k = i;
}
int main()
{
f(1);
return 0;
}
----------------------
#include <iostream>
using namespace std;
void f(int i)
{
cout << "No ref" << endl;
int k = i;
}
void f(int & i)
{
cout << "With ref" << endl;
int k = i;
}
int main()
{
f(1);
return 0;
}