Hi guys!
I wrote a class "Complex" which is representing complex numbers. Nevermind, I was trying to make it a library so i could use it easily in other projects but when i compiled i always got this an error. This is the log from the compilation.
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\samuel\My Documents\Cpp\New Folder\Makefile.win"
Executing make clean
rm -f Complex.o Project1.ag++.exe -c Complex.cpp -o Complex.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -fexceptions
ar r Project1.a Complex.o
ar: creating Project1.a
ranlib Project1.a
Execution terminated
Here are also the source files first the header then the source,
#ifndef COMPLEX_H
#define COMPLEX_H
#include "math.h"
class Complex{
public:
Complex(): x(0),y(0){}
Complex(double real, double imaginary){x = real; y = imaginary;}
Complex operator+(Complex &C_nr2);
Complex operator-(Complex &C_nr2);
Complex operator*(Complex &C_nr2);
double Real(){ return x;}
void Real (double real){ x = real;}
double Imag(){return y;}
void Imag (double imaginary){y = imaginary;}
double Abs();
double Abs2();
private:
double x, y;
};
#endif
#include "Complex.h"
Complex Complex::operator+(Complex &C_nr2){
Complex sum(C_nr2.Real() + x, C_nr2.Imag()+y);
return sum;
}
//------------------------------------------------------------------------------
Complex Complex::operator-(Complex &C_nr2){
Complex diff( x - C_nr2.Real(), y - C_nr2.Imag() );
return diff;
//------------------------------------------------------------------------------
}
Complex Complex::operator*(Complex &C_nr2){
double im, real;
real = x*C_nr2.Real() - y*C_nr2.Imag();
im = x*C_nr2.Imag() + y*C_nr2.Real();
Complex prod(real , im);
return prod;
}
//------------------------------------------------------------------------------
double Complex::Abs(){
return sqrt(x*x+y*y);
}
double Complex::Abs2(){
return x*x+y*y;
}
Oh and I tried using the library file which came out from the compilation but it didnt work in any project. I linked to the library file and included the header but i didnt work.
Thanx for helping
Sam