plik: Complex.h
#pragma once
class Complex {
private:
double x;
double y;
public:
Complex();
Complex(double a, double b);
~Complex();
Complex(Complex &v);
Complex operator!();
bool operator ==(const Complex &v);
bool operator!=(const Complex &v);
bool operator>(const Complex &v);
bool operator<(const Complex &v);
bool operator>=(const Complex &v);
bool operator<=(const Complex &v);
Complex & operator=(const Complex &v);
Complex operator+(const Complex &v);
Complex operator-(const Complex &v);
Complex operator+=(const Complex &v);
Complex operator-=(const Complex &v);
Complex operator*(const Complex &v);
Complex operator/(const Complex &v);
Complex operator*=(const Complex &);
Complex operator/=(const Complex &v);
};
Plik:Complex.cpp
#include "Complex.h"
#include <iostream>
Complex::Complex() {
this->x = 0;
this->y = 0;
}
Complex::Complex(double a, double b)
{
this->x = a;
this->y = b;
}
Complex::Complex(Complex &v)
{
this->x = v.x;
this->y = v.y;
}
Complex::~Complex()
{
}
Complex & Complex::operator=(const Complex &v)
{
if(&v==this)
return *this;
this->x = v.x;
this->y = v.y;
return *this;
}
Complex Complex::operator!()
{
return Complex( -this->x, -this->y);
}
bool Complex::operator==(const Complex &v)
{
if(this->x==v.x && this->y==v.y)
{
return true;
}
else
{
return false;
}
}
bool Complex::operator!=(const Complex &v)
{
if(this->x!=v.x && this->y!=v.y)
{
return true;
}
else
{
return false;
}
}
bool Complex::operator>(const Complex &v)
{
if(this->x > v.x&& this->y > v.y)
{
return true;
}
else
{
return false;
}
}
bool Complex::operator<(const Complex &v)
{
if(this->x < v.x && this->y < v.y)
{
return true;
}
else
{
return false;
}
}
bool Complex::operator>=(const Complex &v)
{
if(this->x>=v.x && this->y>=v.y)
{
return true;
}
else
{
return false;
}
}
bool Complex::operator<=(const Complex &v)
{
if(this->x<=v.x && this->y<=v.y)
{
return true;
}
else
{
return false;
}
}
Complex Complex::operator+(const Complex &v)
{
return Complex(this->x + v.x, this->y + v.y);
}
Complex Complex::operator-(const Complex &v)
{
return Complex(this->x - v.x, this->y - v.y);
}
Complex Complex::operator*(const Complex &v)
{
Complex wynik;
wynik.x = this->x * v.x;
wynik.y = this->y * v.y;
return wynik;
}
Complex Complex::operator/(const Complex &v)
{
Complex ret;
ret.x = this->x * v.x;
ret.y = this->y * v.y;
return ret;
}
Complex Complex::operator+=(const Complex &v)
{
this->x += v.x;
this->y += v.y;
return *this;
}
Complex Complex::operator-=(const Complex &v)
{
this->x -= v.x;
this->y -= v.y;
return *this;
}
Complex Complex::operator*=(const Complex &v)
{
this->x *= v.x;
this->y *= v.y;
return *this;
}
Complex Complex::operator/=(const Complex &v)
{
this->x /= v.x;
this->y /= v.y;
return *this;
}
Wywala mi takie oto błędy:
C:\Dev-Cpp\Complex.cpp In member function Complex Complex::operator!()': C:\Dev-Cpp\Complex.cpp no matching function for call to
Complex::Complex(Complex)'
C:\Dev-Cpp\Complex.cpp In member function Complex Complex::operator+(const Complex&)': C:\Dev-Cpp\Complex.cpp no matching function for call to
Complex::Complex(Complex)'
C:\Dev-Cpp\Complex.cpp In member function Complex Complex::operator-(const Complex&)': C:\Dev-Cpp\Complex.cpp no matching function for call to
Complex::Complex(Complex)'
Nie mogę rozgryźć dlaczego..
const
nie musi być nigdzie)