I'm going to make a Header File complex.h, to get this code to work.
Code:
#include <iostream>
#include "complex.h"
using namespace std;
int main()
{
complex A(1,2); //real = 1, imaginary = 2
cout << "A = " << A.finReal()
<< " + j(" << A.finImaginary() << ")";
cout << " = " << A.abs() << "/_ " << A.vink()
<< " rad" << endl;
//Get print: A = 1 + j(2) = 2.23607/_1.10715 row
complex B(1,3);
complex C;
C = A.time(B);
C.conjugate();
cout << "C = " << C.finReal()
<< " + j(" << C.finImaginary() << ")";
cout << endl;
system("pause");
return 0;
} //main()
What I have trouble with is multiplying complex A (1.2) with complex B (1.3) that works with C = A.time(B); do not know quite how to begin. Here is the code I have found out so far
Code:
#include <iostream>
#include <cmath>
using namespace std;
class complex {
private:
double Real, Imaginary, R, V;
public:
complex(double r, double i){
Real = r;
Imaginary = i;
}
complex(){
Real = 0;
Imaginary = 0;
}
//??
time() {
}
//??
double finReal() {
return Real;
}
double finImaginary() {
return Imaginary;
}
double abs() {
R = sqrt((pow(Real, 2))+(pow(Imaginary, 2)));
return R;
}
double vink() {
V = atan(Imaginary/Real);
return V;
}
double conjugate() {
Imaginary = (-1)*Imaginary;
return Imaginary;
}
};
Bookmarks