c++ - Invalid cast from Complex* to double -
i have homecoming distance between 2 complex numbers , error in homecoming line saying "invalid cast complex* double".
double complex::distance(const complex &a, const complex &b) { complex *number = new complex(); number->modificare(a.real() - b.real()); number->modificaim(a.imag() - b.imag()); homecoming (double)number; }
could please tell me i'm doing wrong? not mention teacher gave definition of function "static double" getting error removed "static".
if remember correctly distance can calculated using pythagorus - creating complex object in distance() not necessary.
double complex::distance(const complex &a, const complex &b) { double x = a.real() - b.real(); double y = a.imag() - b.imag(); homecoming sqrt(x * x + y * y); }
c++ casting double
No comments:
Post a Comment