Advertisement
shmuelazrad

Untitled

Dec 11th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include "pch.h"
  2. #pragma once
  3. #include "cComplex.h"
  4. #include <iostream>
  5. using namespace std;
  6.  
  7.  
  8. int cComplex ::  num = 0;
  9.  
  10. cComplex::cComplex(double x , double y)
  11. {
  12.     realy = x;
  13.     imaginary = y;
  14. }
  15.  
  16.  
  17. cComplex::~cComplex()
  18. {
  19.     num++;
  20.     cout << "Destructor!@#" << endl;
  21.     cout << num << endl;
  22.    
  23. }
  24. void cComplex::print()const
  25. {
  26.     cout <<  realy << "I*" << imaginary << endl;
  27.  
  28. }
  29.  
  30. cComplex cComplex ::operator+(const cComplex &x)
  31. {
  32.     cComplex a;
  33.     a.realy = x.realy + this->realy;
  34.     a.imaginary = x.imaginary + this->imaginary;
  35.     return a;
  36.  
  37. }
  38.  
  39. cComplex & cComplex ::operator+=(const cComplex &x)
  40. {
  41.     this->realy += x.realy;
  42.     this->imaginary += x.imaginary;
  43.     return *this;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement