2.2.3.3.1 complex::complex

Description

Default constructor which constructs a complex value with both the real and the imaginary part being zero.


Constructor which constructs a complex value with the only one argument such that the real part becomes the value of the argument and the imaginary part is zero.


Constructor which constructs a complex value from the real and imaginary values.


Constructor which constructs a complex value from another complex value.

Syntax

complex( )


complex( double dReal )


complex( double dReal, double dImaginary )


complex( complex cc )

Parameters

dReal
the real part
dReal
the real part
dImaginary
the imaginary part
cc
the source complex value

Return

Examples

EX1

void    complex_ex1()
{
    complex        c;
    
    // Display the value:
    out_complex("value = ", c); // Result is "value = 0.000000+0.000000i"
}


EX2

void    complex_ex2()
{
    complex        c(7.89);
    
    // Display the value:
    out_complex("value = ", c); // Result is "value = 7.890000+0.000000i"
}


EX3

void    complex_ex3()
{
    complex        c(3.45, 6.78);
    
    // Display the value:
    out_complex("value = ", c); // Result is "value = 3.450000+6.780000i"
}


EX4

void    complex_ex4()
{
    complex        cc(1.2, 3.4);
    complex        c(cc);
    
    // Display the value:
    out_complex("value = ", c); // Result is "value = 1.200000+3.400000i"
}

Remark

See Also

Header to Include

origin.h