I am reading about C++ references. I came about the code that cannot compile. Here is the code:
On my compiler, it says Initialization of non-const reference type 'int&' from rvalue of type 'int'. Can someone tell me the reason for this? What does it say in the C++ Standard regarding this?
Just for clarification, is the numeric literal '1' a constant?
Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.
- janvier -
Code:
int& i = 1 ; // this will cause a compiler error
const int& j = 1 ; // this works
On my compiler, it says Initialization of non-const reference type 'int&' from rvalue of type 'int'. Can someone tell me the reason for this? What does it say in the C++ Standard regarding this?
Just for clarification, is the numeric literal '1' a constant?
Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.
- janvier -