Klasa liczb zespolonych, struktura

0

Piszę klasę, która pozwala pracować z liczbami zespolonymi. Jest to na razie tylko schemat, który obrazuje jaka funkcjonalność będzie konieczna. Na razie sprawa tylko koncepcyjna. Co byście dodali, odjęli w tym przypadku?

class Complex {
	public:	
		Complex(double _Re = 0.00, double _Im = 0.00);
		Complex(double _Mod, double _Arg /*rad*/);
		Complex(Complex& _Dig);
		
		double getIm();
		double getRe();
		double getMod();
		double getArg();
		
		Complex& getConjugate();
		
		void setIm(double _Im = 0.00);
		void setRe(double _Re = 0.00);
		void setArg(double _Arg);
		
		Complex& operator= (Complex& _Dig);
		Complex& operator+ (Complex& _Dig);
		Complex& operator- (Complex& _Dig);
		Complex& operator/ (Complex& _Dig);
		Complex& operator* (Complex& _Dig);
		
		void& operator+= (Complex& _Dig);
		void& operator-= (Complex& _Dig);
		
		void operator-- (int);
		void operator--();
		void operator++();
		void operator++(int);
		
	private:
		double evalMod() {}
		double evalConjugate() {}
		double evalArg();
		
		double Im;
		double Re;
		double Mod;
		double Arg;
		
};
0

Wywalił bym gettery i settery części całkowitej i urojonej, zamiast tego dając publiczne pola. Wywalił bym pola dla argumentu i modułu, one powinne być liczone dynamicznie. Wywalił bym operatory inkrementacji i dekrementacji, bo są mylące. Słowem zrobił bym tak:

class Complex {
public:
    double re;
    double im;

    Complex(double real, double imaginary = 0.0);
    Complex(const Complex&);
    static Complex from_polar(double arg, double mod); // by uniknąć dwuznaczności mamy dodatkową statyczną metodę
    static Complex from_matrix(Matrix<2, 2> matrix);

    Complex getConjugate() const; // czemu zwracałeś referencję? Do czego? Tu tworzysz nową liczbę.
    
    Complex& operator =(const Complex& other) const;
    Complex& operator +(const Complex& other) const;
    Complex& operator -(const Complex& other) const;
    Complex& operator /(const Complex& other) const;
    Complex& operator *(const Complex& other) const;
 
    Complex& operator +=(const Complex& other); // referencja do void? Co to za bzdura. Piszesz tak
    Complex& operator -=(Complex& other);
    Complex& operator *=(Complex& other);
    Complex& operator /=(Complex& other);

    bool operator ==(const Complex& other) const; // zapomniałeś o porównaniu

    double argument() const;
};

double abs(const Complex&);
#define mod(x) abs(x)

/* Od siebie bym dodał
 * Complex operator "i"(double val) { return Complex(0, val); }
 *
 * oraz
 *
 * Complex operator +(double re, Complex z);
 * Complex operator -(double re, Complex z);
 * Complex operator *(double re, Complex z);
 * Complex operator /(double re, Complex z);
 */

1 użytkowników online, w tym zalogowanych: 0, gości: 1