In C++ Primer 2.2.1 Variable Definitions chapter They said initialize with a curly brace is called list initialize and they said When used with variables of built-in type, this form of initialization has one important property: The compiler will not let us list initialize variables of built-in type if the initializer might lead to the loss of information:
long double ld = 3.1415926536;
int a{ld}, b = {ld}; // error: narrowing conversion required
int c(ld), d = ld; // ok: but value will be truncated
So I thought this is the difference between list initialization and other initializations. But when I tried to check it. I saw that it is working fine! And only they give some warnings(They said error). So I didn't understand anything from this. So can someone tell me what is the difference between normal initializations and list initialization?
Aucun commentaire:
Enregistrer un commentaire