I'm trying to achieve this using parameter overloading using C++:
Complex c(3.0, 4.0);
double magnitude = | c; // magnitude will be 5
I wrote the following code: (Only the necessary part here..)
class Complex
{
   public:
       double _real;
       double _imaginary;
       friend double operator|(const Complex &c1)
       {
           return sqrt(c1._real * c1._real + c1._imaginary * c1._imaginary);
       }
}
But I get the following error:
error C2805: binary 'operator |' has too few parameters
Is that impossible to use operator | with only 1 parameter?
 
     
     
     
     
     
    