cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
What is "Narrowing"
What is "Narrowing"
Dec 12, 2017 at 8:34pm UTC
oahz
(10)
Or what is "Narrowing Conversion"?
Dec 12, 2017 at 8:41pm UTC
Repeater
(3046)
You've got a number being stored in a whole lot of bytes, and then you're turning it into a number stored in a lot fewer bytes. The risk is losing precision, or just getting a completely different number altogether.
Dec 12, 2017 at 9:08pm UTC
oahz
(10)
Well then how come this:
bool b = 7;
is ok.
But
bool b {7};
requires a narrowing conversion?
Dec 12, 2017 at 9:32pm UTC
Cubbi
(4774)
because narrowing conversions are permitted in copy-initialization and forbidden in list-initialization
Topic archived. No new replies allowed.