Operator.cpp
#include <iostream>
class Nothing
{
public:
Nothing() { Bogus=0;}
Nothing& operator+( const Nothing& A )
{ cout << "Nothing::operator+ called" << endl; return(*this); }
friend Nothing& operator*( const Nothing& A, const Nothing& B );
private:
int Bogus;
};
const Nothing& operator-( const Nothing& A, const Nothing& B )
{
cout << "operator- called" << endl;
return(A);
}
Nothing& operator*(const Nothing& A, const Nothing& B )
{
if( A.Bogus == 0 )
{
}
cout << "Operator* can access private data because it's a friend" << endl;
}
int main()
{
Nothing A, B;
A + B;
A - B;
A * B;
}