4.5.  ____________________________________115

switch (x.t) {  //   
case int_type:

v = x.d.i;    //v - 

breaks-
case dbl_type:

 = x.d.i;    //   

break;

)

       .    t 
      . - C++ -
  ,         
 .

4.5.  

      .  
  .

  complexl.cpp

struct complex {

double real, imag;

};

void assign(complex* pc, double r, double i = 0.0)
{

pc -> real = r;

pc -> imag = i;

}

complex add(complex a, complex b)
{

complex temp;

temp.real = a.real + b.real;

temp.imag = a.imag + b.imag;

return temp;

}

 ,      ,   
     .    
   .

       :

double f = 2.5;

complex w, x, z;

assign(&x, 5.5, -3.2);    //x = 5.5 - 3.2i
assignf&w, f);            //w = 2.5 - Oi
z = add(w, x);            //2=8.0-3.21