Yes... here is the whole picture.
Code:
#ifndef COMPLEX_H
#define COMPLEX_H
#include <iostream>
using namespace std;
class Complex {
friend ostream &operator<<( ostream&, const Complex & );
friend istream &operator>>( istream&, Complex & );
private:
int real;
int imaginary;
};
#endif
Code:
#include "complex.h"
ostream &operator<<( ostream &output, const Complex &num ){
output << "The real value of the complex number is " << num.real << "." << "\n"
<< "The imaginary value of the complex number is " << num.imaginary << "." <<"\n";
return output;
}
istream &operator>>( istream &input, Complex &num ){
input >> num.real;
input >> num.imaginary;
return input;
}
Code:
#include "complex.h"
int main() {
Complex complex;
while !(complex == EOF){
cout << "Enter complex number (^Z to end): ";
cin >> complex;
cout << complex;
}
return 0;
}