need someone to check my coding
hi.
i am doing a question from the book on c++ and would like all of you to check the errors..
this is about adding complex numbers
but i am getting many errors can some check what's wrong
Code:
#include<iostream>
using namespace std;
class complexNumber
{
private:
float realPart;
float imgPart;
static int count;
public:
complexNumber ( float real=0,float img=0);
void show();
static int getcount() { return count;};
void incr();
friend int add( complexNumber, complexNumber):complexNumber
};
complexNumber :: complexNumber( float real , float img)
{
realPart = real;
realPart = real;
count ++;
}
void complexNumber :: show()
{
cout<< realPart<< "+"<< imgPart<<"i"<<endl;
}
int add( complexNumber &a, complexNumber &b): complexNumber &c
{
c.realPart = a.realPart + b.realPart;
c.imgPart = a.realPart + b.realPart;
return c;
}
void complexNumber :: incr()
{
complexNumber a;
a.realPart++;
return 0;
}
int main()
{
complexNumber a(2.0, 1.0);
a.incr();
a.show();
return 0;
}
i can't get it actually how to define <<friend>> add( complexNumber , complexNumber) :
complexNumber
and my incr() function is wrong..it is a member method that increments the complex object by 1 and effect the real part and return nothing