Why does this one list initialization work but not the other?

33 views Asked by At

The first two statements int a{ ld }; int b = { ld }; produce compiler errors C3297 and won't compile, but the 2nd definition/initialization with the parentheses works. Why?

#include<iostream>
using namespace std;
int main()
{
    
    long double ld = 3.1415926536;

    int a{ ld };
    int b = { ld };
    int c(ld);
    int d = ld;

    std::cin.get();
    std::cin.get();
    return 0;

}
0

There are 0 answers