The header file includes prototypes for the public member function, definitions for the private data members, and prototypes for the (external) convenience functions.
//
// Defining the class rational
// -- third attempt -- separate compilation
//
// by A.B. Maccabe 2/27/97
//
#ifndef RATIONAL_H
#define RATIONAL_H
#include <iostream.h>
class Rational {
public:
// Constructors
Rational( int n = 0, int d = 1 );
// I/O
void read( istream &in );
void write( ostream &out );
// arithmetic
Rational neg( );
Rational add( Rational rat );
Rational sub( Rational rat );
Rational mpy( Rational rat );
Rational div( Rational rat );
private:
int num, denom;
};
// define overloaded operators
Rational operator +( Rational r1, Rational r2 );
ostream & operator <<( ostream &os, Rational r );
istream & operator >>( istream &is, Rational &r );
#endif // RATIONAL_H