According to this question you can\'t change what a reference refers to. Likewise the C++ Primer 5th Edition states
Once we have defined a reference,
You are not reassigning a reference. A reference acts as an alias for a variable. In this case, ref is an alias for a, so
ref
a
ref = b;
is the equivalent of
a = b;
You can easily check that by printing out the value of a:
std::cout << a << std::endl; // prints 4