The header file is as follows:
#include<iostream>
class Crate{
private:
int z,x,y,w;
public:
friend ostream& operator1<<(ostream& output, const Crate& H);
friend ostream& operator2<<(ostream& output);
friend ostream& operator3<<(ostream& output);
};
The class code for the definition:
#include<iostream>
#include "Crate.h"
using namespace std;
ostream& operator1<<(ostream& output, const Crate& w) {
output << w.z=w;
return output;
}
ostream& operator2<<(ostream& output, const Crate& x) {
output << x=x.w*3;
return output;
}
ostream& operator3<<(ostream& output, const Crate& y) {
output << y=x.w*4;
return output;
}
};
As the functions in the header file class are friend functions, they can be called directly without reference of the same class.