Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef COMPLEX_H_INCLUDED
- #define COMPLEX_H_INCLUDED
- #include <iostream>
- using namespace std;
- class Complex
- {
- private:
- double real, imag;
- public:
- // Konstruktori
- Complex();
- Complex(double, double);
- Complex(const Complex&);
- double getReal() const;
- double getImag() const;
- void setReal(double);
- void setImag(double);
- Complex& operator=(const Complex&);
- Complex& operator+=(const Complex&);
- Complex& operator-=(const Complex&);
- Complex& operator*=(const Complex&);
- Complex& operator/=(const Complex&);
- const Complex& operator++();
- const Complex operator++(int);
- friend Complex operator+(const Complex&, const Complex&);
- friend Complex operator-(const Complex&, const Complex&);
- friend Complex operator*(const Complex&, const Complex&);
- friend Complex operator/(const Complex&, const Complex&);
- friend bool operator==(const Complex&, const Complex&);
- friend bool operator!=(const Complex&, const Complex&);
- friend ostream& operator<<(ostream&, const Complex&);
- friend istream& operator>>(istream&, const Complex&);
- };
- #endif // COMPLEX_H_INCLUDED
- /* Errors:
- D:\FTN\Programiranje\Complex\complex.h||In function 'std::istream& operator>>(std::istream&, Complex&)':|
- D:\FTN\Programiranje\Complex\complex.h|10|error: 'double Complex::real' is private|
- D:\FTN\Programiranje\Complex\complex.cpp|156|error: within this context|
- D:\FTN\Programiranje\Complex\complex.h|10|error: 'double Complex::imag' is private|
- D:\FTN\Programiranje\Complex\complex.cpp|156|error: within this context|
- ||=== Build finished: 4 errors, 0 warnings ===|
- */
- // complex.cpp:
- istream &operator>>(istream &in, Complex &z)
- {
- in >> z.real >> z.imag;
- return in;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement