I am trying to operator overload for a complex number, I have implemented a class where it takes in real and imaginary part. I am trying to overload the %
operator where it return a modulus value(length of the real and imaginary), but I am getting error "must take exactly one argument", What am I doing wrong?
Here is my header file
complex.h
class complex{
private:
double rm;
double im;
public:
void operator % ();
complex.cpp
void operator %(){
complex c;
c.re = pow(re,2);
c.im = pow(im,2);
return c;
Thank you!
%
is a binary operator. – molbdnilocomplex operator%(const complex& other);
– pptaszni