double & val = 66.6; //illegal
const double & val = 66.6; //legal
I was just doing some demo programs and came through the above concept but not able to identify what exactly the need of the above concept . what magic exactly const is doing in the second case ?
can anyone please let me know where exactly we can use this concept in real time programming
vikuseth
0
Newbie Poster
Recommended Answers
Jump to Postwhat magic exactly const is doing in the second case ?
I think a better question is how would having a non-const reference to a literal value work? A non-const reference basically says "I'm referring to an object with an address whose value can be modified". A literal …
All 3 Replies
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
vikuseth
0
Newbie Poster
Gonbe
32
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.