Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <memory>
- #include <cmath>
- using namespace std;
- ///// zadanie 6
- class extended_complex
- {
- float re, im;
- public:
- extended_complex(float re = 0, float im = 0) : //konstruktor
- re(re), im(im)
- {
- }
- float real()
- {
- return re;
- }
- void real(float rr)
- {
- re = rr;
- }
- float img()
- {
- return im;
- }
- void img(float ii)
- {
- im = ii;
- }
- void print()
- {
- cout << mod() << "," << arg();
- }
- double mod()
- {
- return(sqrt(re*re+im*im));
- }
- double arg()
- {
- return atan2(im,re);
- }
- };
- int main()
- {
- ////// zadanie 8
- extended_complex *x = new extended_complex(77, -5); //dynamiczne tworzenie obiektu
- extended_complex y = *x; //przypisanie
- y.print(); //wyswietlenie
- delete x; //skasowanie dynamicznego obiektu
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement