Why is it allowed to pass R-Values by const reference but not by normal reference?

Viewed 14938

The following program

void display(const int& a)
{
    cout << a ;
}

will work if called with a literal like this

display(5);

but without the const it won't work.

So how can a const reference keep pointing to an R-Value (anonymous variable)?

5 Answers
Related