I'm trying to compile something like this:
int f(int a){
    return a+2;
}
void g(int& a){
    a++;
}
int main(){
    int a=5;
    g(f(a));
} 
but I get the error:
error: invalid initialization of non-const reference of type 'int&' from an rvalue of type 'int'
at  g(f(a));
Why? How could I solve it?
 
    