Comments (5)
Hi~ @frank67 You are absolutely right. 👍
Could you please propose a pull request for this?
from cpp-primer.
@pezy maybe when @Mooophy wrote that code he want to declare a new reference to "i" the same way he had declared "r" in the "int i = 0, &r = i;" statements but it's also legal to declare a reference ("d") to another reference ("r") as I proposed.
HTH 😄
from cpp-primer.
@frank67 I have to say, @Mooophy is innocent... 😞
This confused answer is wrote by me, and I think I need to give some explanations:
auto
: deduce from the r-value's type. but essentially, thus reference and top-levelconst
are ignored.decltype
: deduce from the expression's type, and comprehensive, thus, including both reference and top-levelconst
.
Then, come back this question, give example for difference:
decltype(r) d = i;
^^
here is the key, i or r (right-hand operand of an assignment) is not the point.
So, IMHO, i
or r
is all okay. 🌝
from cpp-primer.
@pezy but "d" should it be a reference to "i" or "r" in that contest? Since it's legal to declare a reference to another reference for sake of clarity, since "r" was used in previous "c" assignement, I think "d" should be declared as reference of "r".:blush:
from cpp-primer.
@frank67 Agree. 👌
from cpp-primer.
Related Issues (20)
- exercise12.8 memory leakage reason?
- Got this issue
- Typo in exercise 15.34 / 15.36
- Typo in exercise 16.36
- Cpp primer answer
- Access to private member
- Cannot understand exercise 9.52, please help. HOT 1
- ex13.44 about size and length function HOT 1
- D HOT 1
- ex2.5 notation vs type? HOT 1
- Spelling error in "Exercise 4.7" HOT 1
- Spelling error in Exercise 4.14 HOT 1
- Spelling error in Exercise 4.28 HOT 1
- "Include" error in ex15.4.5.6
- Cpp
- Ch 16 - some further reading for ex65 and 66
- A issue made by mistake.
- Ex 14.28 problem
- Ex13.42 HOT 1
- Exercise 10_32.cc (G++ giving error on the accumulate algorithm)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpp-primer.