Share via


istream_iterator::operator->

Returns the value of a member, if any.

const Type* operator->( ) const;

Return Value

The value of a member, if any.

Remarks

i -> is equivalent to (*i).m

The operator returns &**this.

Example

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

using namespace std;

int main( )
{
   cout << "Enter complex numbers separated by spaces & then\n"
        << " a character pair ( try example: '(1,2) (3,4) (a,b)' ): ";

   // istream_iterator from stream cin
   istream_iterator< complex<double> > intRead ( cin );

   // End-of-stream iterator
   istream_iterator<complex<double> > EOFintRead;

   while ( intRead != EOFintRead )
   {
      cout << "Reading the real part: " << intRead ->real( ) << endl;
      cout << "Reading the imaginary part: " << intRead ->imag( ) << endl;
      ++intRead;
   }
   cout << endl;
}
  (1,2) (3,4) (a,b)
  (1,2) (3,4) (a,b)
Enter complex numbers separated by spaces & then
 a character pair ( try example: '(1,2) (3,4) (a,b)' ): (1,2) (3,4) (a,b)
Reading the real part: 1
Reading the imaginary part: 2
Reading the real part: 3
Reading the imaginary part: 4

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

istream_iterator Class

Standard Template Library