Possible Duplicate:
How come a non-const reference cannot bind to a temporary object?
There is such code:
void fun_ref(int& par){}
void fun_const_ref(const int& par){}
int main(){
//fun_ref(2); error: invalid initialization of non-const reference of type ‘int&’ from a temporary of type ‘int’
fun_const_ref(2);
char var = 3;
//fun_ref(var); error: invalid initialization of reference of type ‘int&’ from expression of type ‘char’
fun_const_ref(var);
return 0;
}
Why is it possible to pass rvalue and different data type than type of function parameter for constant reference, but it is not possible for non-constant reference?