Pegun
Golden Member
I'm having a problem with the program I'm experimenting with. I'm trying to do a problem that will add and subtract complex numbers (real + imag*i). I'm getting an unresolved external symbol error within the add and subtract parts at the main function. Heres the code:
// Imaginary.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "cmath"
#include "Complex.h"
float i;
/*class Complex
//note: complex.h
{
public:
Complex(int a=0, int b=0);
Complex add(Complex &,Complex &);
Complex sub(Complex &,Complex &);
void print();
private:
int real;
int imaginary;
};*/
int _tmain(int argc, _TCHAR* argv[])
{
i = pow(-1.,0.5);
Complex num1(2, 5), num2(7, 8), num3, num4 ;
num1.print();
num2.print();
num3.add(num1,num2); // num3=num1+num2
num3.print();
num4.sub(num1,num2); //num4= num1-num2
num4.print();
return 0;
}
Any help is appreciated.
// Imaginary.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "cmath"
#include "Complex.h"
float i;
/*class Complex
//note: complex.h
{
public:
Complex(int a=0, int b=0);
Complex add(Complex &,Complex &);
Complex sub(Complex &,Complex &);
void print();
private:
int real;
int imaginary;
};*/
int _tmain(int argc, _TCHAR* argv[])
{
i = pow(-1.,0.5);
Complex num1(2, 5), num2(7, 8), num3, num4 ;
num1.print();
num2.print();
num3.add(num1,num2); // num3=num1+num2
num3.print();
num4.sub(num1,num2); //num4= num1-num2
num4.print();
return 0;
}
Any help is appreciated.