#includeiostream
using namespace std;
class Complex {
public:
Complex( double r= 0.0, double m = 0.0 ):
real(r),imaginary(m){
}
// constructor
Complex operator ( const Complex// addition
Complex operator-( const Complex
//subtraction
const Complex
// assignment
void shownum(){
coutreal\" \"imaginaryendl;
}
private:
double real;
// real part
double imaginary;// imaginary part
};
const Complex
imaginary = right.imaginary;
return *this;
}
Complex Complex::operator (const Complex
}
// Overloaded subtraction operator
Complex Complex::operator- (const Complex
}
int main(){
Complex x, y( 4.3, 8.2 ), z( 3.3, 1.1 );
x = y z; //
x = y - z;
//
}
|