My class is as follows.
-----------------------------------
class complex{
private:
double real, imag;
public:
complex ();
complex (double r, double i);
complex (const complex& a);
void in (double r, double i);
void in (complex& a);
friend istream& operator>> (istream& s,
complex& c);
friend ostream& operator<< (ostream& s,
complex& c);
complex operator+ (complex& a);
complex operator- (complex& a);
complex operator* (complex& a);
friend complex operator* (double a, complex& b);
complex operator/ (complex& a);
complex operator~ ();
complex operator^ (int b);
double get_real();
double get_imag();
double mod();
double arg();
};
--------------------------------
I've used 3 friend functions. The istream and ostream
functions are visible in the class browser but the "friend
complex operator* (double a, complex& b)" function is not
visible. It works perfectly but experience has shown that if
its not seen in the browser, there's something wrong
somewhere. The implementation of this function is as follows.
----------------------------------
complex operator* (double a, complex& b)
{
complex temp;
temp.real=a*b.real;
temp.imag=a*b.imag;
return temp;
}
-------------------------------------
Any faults that I've missed?
TIA.
--
Rohit V. Bhute
http://rvbhute.blogspot.com/
|