Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- class complex {
- private:
- double real;
- double imagine;
- double bufer1;
- double bufer2;
- public:
- complex();
- complex(double a, double b);
- void operator+(complex x);
- void operator-(complex x);
- void operator*(complex x);
- void operator/(complex x);
- ~complex();
- void printer();
- };
- complex :: complex() {
- real = 0;
- imagine = 0;
- }
- complex::~complex() {
- cout << "Bye-Bye" << endl;
- }
- complex::complex(double a, double b) {
- real = a;
- imagine = b;
- }
- void complex::operator+(complex x) {
- bufer1 = x.real + real;
- bufer2 = x.imagine + imagine;
- }
- void complex::operator-(complex x) {
- bufer1 = real - x.real;
- bufer2 = imagine - x.imagine;
- }
- void complex::operator*(complex x) {
- bufer1 = real * (x.real) - imagine * x.imagine;
- bufer2 = real * (x.imagine) + imagine * x.real;
- }
- void complex::operator/(complex x) {
- bufer1 = (real*x.real - imagine * x.imagine) / (x.real*x.real + x.imagine*x.imagine);
- bufer2 = (imagine * x.real - real * x.imagine) / (x.real*x.real + x.imagine*x.imagine);
- }
- void complex::printer() {
- cout << bufer1 << "+" << "i*" << bufer2 << endl;
- }
- int main() {
- double a, b,c,d;
- cin >> a >> b;
- //complex first;
- complex *first = new complex(a,b);
- cin >> c >> d;
- //complex second;
- complex *second = new complex(c, d);
- //first.printer();
- cout << "summa" << endl;
- first = first+*second;
- first->printer();
- //delete first;
- //complex *first = new complex(a, b);
- cout << "minus" << endl;
- first->minus(*second);
- first->printer();
- //delete first;
- //complex *first = new complex(a, b);
- cout << "mnoji" << endl;
- first->mult(*second);
- first->printer();
- //delete first;
- //complex *first = new complex(a, b);
- cout << "del" << endl;
- first->del(*second);
- first->printer();
- //complex first(a, b);
- delete first;
- delete second;
- complex *third = new complex();
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement