mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Move comment in c++.html.markdown (#4979)
This commit is contained in:
parent
06383371ef
commit
887d6e0653
@ -263,10 +263,10 @@ std::string& fooRef = foo; // This creates a reference to foo.
|
|||||||
fooRef += ". Hi!"; // Modifies foo through the reference
|
fooRef += ". Hi!"; // Modifies foo through the reference
|
||||||
std::cout << fooRef; // Prints "I am foo. Hi!"
|
std::cout << fooRef; // Prints "I am foo. Hi!"
|
||||||
|
|
||||||
|
std::cout << &fooRef << '\n'; // Prints the address of foo
|
||||||
// Doesn't reassign "fooRef". This is the same as "foo = bar", and
|
// Doesn't reassign "fooRef". This is the same as "foo = bar", and
|
||||||
// foo == "I am bar"
|
// foo == "I am bar"
|
||||||
// after this line.
|
// after this line.
|
||||||
std::cout << &fooRef << '\n'; // Prints the address of foo
|
|
||||||
fooRef = bar;
|
fooRef = bar;
|
||||||
std::cout << &fooRef << '\n'; // Still prints the address of foo
|
std::cout << &fooRef << '\n'; // Still prints the address of foo
|
||||||
std::cout << fooRef << '\n'; // Prints "I am bar"
|
std::cout << fooRef << '\n'; // Prints "I am bar"
|
||||||
|
Loading…
Reference in New Issue
Block a user