add Chapter06
This commit is contained in:
26
Chapter06/lvalue_refs.cpp
Normal file
26
Chapter06/lvalue_refs.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
int a = 42;
|
||||
|
||||
int& a_ref = a;
|
||||
|
||||
const int& a_const_ref = a;
|
||||
|
||||
|
||||
printf("a = %d\r\n", a);
|
||||
|
||||
|
||||
a_ref = 16;
|
||||
|
||||
printf("a = %d\r\n", a);
|
||||
|
||||
|
||||
// a_const_ref = 16; compiler error
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user