I've been going through a book (C++ Programming Language Stroustrup 4th ed). An example given in a section related to Initialization as below:
void f(double d, int i)
{
int a{ d }; // error : possible truncation
char b{ i }; // error : possible narrowing
}
What exactly is the difference between truncation and narrowing?
Aucun commentaire:
Enregistrer un commentaire