mardi 2 juin 2020

complex<> using list initializer vs constructor?

I'm reading Stroustrup C++ 4th Ed. Page 162 Types and Declarations. Specifically, where the following is allowed to construct a complex<> object.

The book comments that case A is "use constructor". Is case A really a list initializer and the constructor method of initialization is performed in B or C?

Thanks

#include <iostream>
#include <complex>
using namespace std;

int main(int argc, char *argv[])
{
    complex<double> z = { 0, 3.14 }; // A
    complex<double> h(0, 3.14); // B
    complex<double> i{0, 3.14}; // C

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire