[note 1]
An example of call by reference
#include <iostream>
using namespace std;
void func(int&a)
{
cout<<"in func------"<<++a<<endl;
}
int main(int argc, const char * argv[]) {
int m=1;
cout<<"m-----1 "<<m<<endl;
func(m);
func(2); //illegal
cout<<"m-----2 "<<m<<endl;
return 0;
}
output:
m-----1 1
in func------2
m-----2 2
[note 2]
function overloading
- if the conversion is possible to have multiple matches, then the compiler will generate an error message.
[example]
long square(long n);
double square(double n);
square(10); //will generate an error