Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Complex {
- int Re, Im;
- public:
- Complex():Re(1),Im(1){}
- Complex(int a, int b):Re(a),Im(b){}
- void setRe(int a) { Re = a; }
- void setIm(int a) { Im = a; }
- double getRe() { return Re; }
- double getIm() { return Im; }
- Complex zbroj(const Complex& lhs, const Complex& rhs) {
- Complex novi;
- novi.Re = lhs.Re + rhs.Re;
- novi.Im = lhs.Im + rhs.Im;
- return novi;
- }
- };
- int main() {
- Complex broj1;
- Complex broj2(2,2);
- Complex rezultat = zbroj(broj1, broj2);
- cout << "novi broj je jednak:" << rezultat.getRe() << " + " << rezultat.getIm() << "i" <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement