Need help(complex no. class)
Hello,,
I have made a class of complex numbers with functionality that it can add and subtract. But i get loads of errors in it . Can anybudy help me.
Code:
#include<iostream.h>
#include<conio.h>
#include<math.h>
class complex
{ int r;
int i;
public:
complex (int a, int b)
{
r=a;
i=b;
}
void input ()
{
cin>>r>>i;
}
complex add(complex k)
{
complex add;
add.r=r+k.r;
add.i=i+k.i;
return add;
}
complex sub(complex q)
{
complex sub;
sub.r=r-q.r;
sub.i=i-q.r;
return sub;
}
void print()
{
cout<<r;
cout<<i;
}
int main()
{ class d,e;
complex c(7,8);
d.input();
e=c.add(d);
e.print();
e=c.sub(d);
e.print();
return 0;
}