class complex1
{
public:
int real,img;
complex1(){}
complex1(int a)
{
real=a;
img=a;
}
complex1(int a,int b)
{
real=a;
img=b;
}
complex1 sum(int x,complex1 y);
complex1 sum(complex1,complex1);
complex1 display(complex1);
};
complex1 complex1::sum(int x,complex1 y)
{
complex1 num;
num.real=x+y.real;
num.img=y.img;
return num;
}
complex1 complex1::sum(complex1 a,complex1 b)
{
complex1 num;
num.real=a.real+b.real;
num.img=a.img+b.img;
return num;
}
complex1 complex1::display(complex1 c)
{
cout<<"The complex number is:\n";
cout<<c.real<<"+i"<<c.img;
}
main()
{
complex1 p,q,r,s;
p=complex1(2,4);
q=complex1 (3,5);
cout<<"\n";
cout<<"p="<<display(p);
cout<<"q="<<display(q);
}
Using constructors we need to add two complex numbers. I get the error
Error: display was not declared in this scope.
Any suggestions? where am I wrong?