Aracılığıyla paylaş


complex::operator+=

Bir hedef karmaşık sayı bir sayı ekler, eklenen sayı karmaşık olabilir ve aynı türde olduğu için onu eklenir karmaşık sayının reel ve sanal kısımları olur.

template<class Other>
   complex<Type>& operator+=(
      const complex<Other>& _Right
   );
complex<Type>& operator+=(
      const Type& _Right
   );
complex<Type>& operator+=(
      const complex<Type>& _Right
   );

Parametreler

  • _Right
    Karmaşık bir sayının veya aynı tür hedef karmaşık sayının parametresi olarak bir sayı.

Dönüş Değeri

Eklenen bir parametre tarafından belirtilen sayı olan karmaşık sayı.

Notlar

Böylece belirli bir biçimde veri dönüştürme olmadan basit aritmetik işlemleri yürütülen işlem aşırı yüklendi.

Örnek

// complex_op_pe.cpp
// compile with: /EHsc
#include <complex>
#include <iostream>

int main( )
{
   using namespace std;
   double pi = 3.14159265359;

   // Example of the first member function
   // type complex<double> added to type complex<double>
   complex <double> cl1 ( 3.0 , 4.0 );
   complex <double> cr1 ( 2.0 , -1.0 );
   cout << "The left-side complex number is cl1 = " << cl1 << endl;
   cout << "The right-side complex number is cr1 = " << cr1 << endl;

   complex <double> cs1 = cl1 + cr1;
   cout << "The sum of the two complex numbers is: cs1 = cl1 + cr1 = "
        << cs1 << endl;

   // This is equivalent to the following operation
   cl1 += cr1;
   cout << "The complex number cr1 added to the complex number cl1 is:"
        << "\n cl1 += cr1 = " << cl1 << endl;

   double abscl1 = abs ( cl1 );
   double argcl1 = arg ( cl1 );
   cout << "The modulus of cl1 is: " << abscl1 << endl;
   cout << "The argument of cl1 is: "<< argcl1 << " radians, which is " 
        << argcl1 * 180 / pi << " degrees." << endl << endl; 

   // Example of the second member function
   // type double added to type complex<double>
   complex <double> cl2 ( -2 , 4 );
   double cr2 =5.0;
   cout << "The left-side complex number is cl2 = " << cl2 << endl;
   cout << "The right-side complex number is cr2 = " << cr2 << endl;

   complex <double> cs2 = cl2 + cr2;
   cout << "The sum of the two complex numbers is: cs2 = cl2 + cr2 = " 
        << cs2 << endl;

   // This is equivalent to the following operation
   cl2 += cr2;
   cout << "The complex number cr2 added to the complex number cl2 is:"
        << "\n cl2 += cr2 = " << cl2 << endl;

   double abscl2 = abs ( cl2 );
   double argcl2 = arg ( cl2 );
   cout << "The modulus of cl2 is: " << abscl2 << endl;
   cout << "The argument of cl2 is: "<< argcl2 << " radians, which is " 
        << argcl2 * 180 / pi << " degrees." << endl << endl;
}
  
  

Gereksinimler

Başlık: <complex>

Namespace: std

Ayrıca bkz.

Başvuru

complex Class