Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef ZESPOLONA_H_INCLUDED
- #define ZESPOLONA_H_INCLUDED
- class Zespolona
- {
- public:
- float re,im;
- Zespolona (float re_ = 0, float im_ = 0)
- {
- re = re_;
- im = im_;
- }
- void dodaj (Zespolona &z) //dodaj2
- {
- re += z.re;
- im += z.im;
- }
- void dodaj (Zespolona &z1, Zespolona &z2) //dodaj3
- {
- re += z1.re + z2.re;
- im += z1.im + z2.im;
- }
- void operator += (Zespolona &z)
- {
- re += z.re;
- im += z.im;
- }
- Zespolona operator + (Zespolona &z)
- {
- Zespolona z_;
- z_.re = re + z.re;
- z_.im = im + z.im;
- return z_;
- }
- bool operator == (Zespolona &z)
- {
- if ((re == z.re) && (im == z.im))
- {
- std::cout << "true" << std::endl;
- return true;
- }
- else
- {
- std::cout << "false" << std::endl;
- return false;
- }
- }
- };
- #endif // ZESPOLONA_H_INCLUDED
- ///////////////main
- #include <iostream>
- #include "zespolona.h"
- using namespace std;
- int main()
- {
- Zespolona a(1,1);
- Zespolona b(2,2);
- Zespolona c(3,3);
- cout << "a.im: " << a.im << " , a.re: " << a.re << endl;
- cout << "b.im: " << b.im << " , b.re: " << b.re << endl;
- cout << "c.im: " << c.im << " , c.re: " << c.re << endl;
- cout << endl;
- cout << "a += b" << endl;
- a += b;
- //a.dodaj(b);
- cout << "a.im: " << a.im << " , a.re: " << a.re << endl;
- cout << endl;
- cout << "b = a + c" << endl;
- b = a + c;
- //a.dodaj(b,c);
- cout << "b.im: " << b.im << " , b.re: " << b.re << endl;
- cout << endl;
- cout << "a == c" << endl;
- a == c;
- cout << endl;
- cout << "b == c" << endl;
- b == c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement