Back to slide -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'          references/const-ref-int.cc - The initialization of const reference var from rvalue, with type conversion.Lecture 2 - slide 16 : 29
Program 1

// Initializes a const reference with an rvalue, via type conversion.

#include <iostream>

int main(){

  const int &var = 5.3;  // var becomes a const reference to an rvalue 
                         // via some temporary variable. Involves implicit type conversion.

  std::cout << var << std::endl;   // 5

  var = 6;               // ERROR: assignment of read-only reference 'var'
}