Partager via


operator>> (<complex>)

Extracts a complex value from the input stream.

template<class Type, class Elem, class Traits>
   basic_istream<Elem, Traits>&
      operator>>(
         basic_istream<Elem, Traits>& _Istr,
         complex<Type>& _Right
      );

Parameters

  • _Istr
    The input stream from which the complex number is being extracted.

  • _Right
    The complex number that is being extracted from the input stream.

Return Value

Reads the value of the specified complex number from _Istr and returns it into _Right.

Remarks

The valid input formats are

  • ( real part, imaginary part )

  • ( real part )

  • real part

Example

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

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

   complex <double> c2;

   cout << "Input a complex number ( try: 2.0 ): ";
   cin >> c2;
   cout << c2 << endl;
}
  2.0

Requirements

Header: <complex>

Namespace: std

See Also

Other Resources

<complex> Members