I would like to overload the || operator in such a way that I can use it to find the modulus of a complex number. I.E.
Complex z(x0,y0);
double mod = |z|;
Is it possible to do so? If so, how?
Thanks
I would like to overload the || operator in such a way that I can use it to find the modulus of a complex number. I.E.
Complex z(x0,y0);
double mod = |z|;
Is it possible to do so? If so, how?
Thanks
No, that's not possible. There is no |x| operator (there is no such syntax). || is logical OR.
Generally speaking, it's a good idea to avoid writing code that attempts to change the syntax of C++ because it makes the code much less maintainable. Imagine that you figured out a way to create a |x| operator (I don't think there's a way...). The next person that read your code who knew C++ would have no idea what that was.