Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Complex {
  5. int Re, Im;
  6.  
  7. public:
  8.  
  9. Complex():Re(1),Im(1){}
  10. Complex(int a, int b):Re(a),Im(b){}
  11. void setRe(int a) { Re = a; }
  12. void setIm(int a) { Im = a; }
  13. double getRe() { return Re; }
  14. double getIm() { return Im; }
  15.  
  16. Complex zbroj(const Complex& lhs, const Complex& rhs) {
  17. Complex novi;
  18. novi.Re = lhs.Re + rhs.Re;
  19. novi.Im = lhs.Im + rhs.Im;
  20. return novi;
  21. }
  22.  
  23.  
  24. };
  25.  
  26.  
  27. int main() {
  28. Complex broj1;
  29. Complex broj2(2,2);
  30. Complex rezultat = zbroj(broj1, broj2);
  31.  
  32. cout << "novi broj je jednak:" << rezultat.getRe() << " + " << rezultat.getIm() << "i" <<endl;
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement