No, because the non-reference variable will contain the value of the bounded value of the reference.
int value = 100; int &ref_value = value; int new_value = ref_value; std::cout << new_value << "\n"
Output:
100
Oh yeah okay you're dereferencing when assigning to some_value, gotcha. Just another question: if you use auto, what would the inferred type be?
some_value
auto
int value = 100; int &ref_value = value; auto new_value = ref_value;
Does new_value remain a reference or now contains the dereferenced value?
new_value
Not entirely sure as auto in some instances is tricky. I believe in your example that new_value will the type int.
int
It will be int&, I think: en.cppreference.com/w/cpp/language...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
No, because the non-reference variable will contain the value of the bounded value of the reference.
Output:
Oh yeah okay you're dereferencing when assigning to
some_value
, gotcha. Just another question: if you useauto
, what would the inferred type be?Does
new_value
remain a reference or now contains the dereferenced value?Not entirely sure as
auto
in some instances is tricky. I believe in your example thatnew_value
will the typeint
.It will be int&, I think: en.cppreference.com/w/cpp/language...