Slide 8.4: Book_1.h
Slide 8.6: SkipSpaces.h
Home

Overload.h


Also, this operator overloading is rewritten and improved. There is nothing wrong with the previous version.

 ~wenchen/public_html/cgi-bin/351/week8/Overload.h 
#include  <fstream>
#include  <iostream>
#include  <cstring>
  using namespace  std;

#include  "SkipSpaces.h"

istream& operator>> ( istream& stream, Book& b ) {
  char  buffer[129];

  stream.getline( buffer, 129,  '|' );
  SkipSpaces( buffer );
  b.PutValue( 1, buffer );
  if ( strlen( buffer ) == 0 )  return( stream );

  stream.getline( buffer,  32,  '|' );
  SkipSpaces( buffer );
  b.PutValue( 2, buffer );

  stream.getline( buffer,  32,  '|' );
  SkipSpaces( buffer );
  b.PutValue( 3, buffer );

  stream.getline( buffer,  32,  '|' );
  SkipSpaces( buffer );
  b.PutValue( 4, buffer );
  return( stream );
}