class Complex
{
public:
Complex(float = 0.0, float = 0.0); //default constructor that uses default arg. in case no init. are in main
void getComplex(); //get real and imaginary numbers from keyboard
void sum(Complex, Complex); //method to add two complex numbers together
void diff(Complex, Complex); //method to find the difference of two complex numbers
void prod(Complex, Complex); //method to find the product of two complex numbers
void square(Complex, Complex); //method to change each complex number to its square
void printComplex(); //print sum, diff, prod, square and "a+bi" form
private:
float real; //float data member for real number (to be entered in by user)
float imaginary; //float data member for imaginary number (to be entered in by user)
};
void Complex::getComplex()
{
cout << "Enter real number: ";
cin >> real;
cout << "Enter imaginary number: ";
cin >> imaginary;
}
void Complex::sum(Complex, Complex)
{
float sum = 0.0;
sum = real + imaginary;
}
int main()
{
Complex c;
c.getComplex();
c.sum(Complex, Complex);
c.diff(Complex, Complex);
c.prod(Complex, Complex);
c.square(Complex, Complex);
c.printComplex();
return 0;
}
I get an error under c.sum(Complex, Complex);
inside the main (along with the c.diff
, c.prod
, and c.square
lines). The error is:
type name Complex is not allowed
and too few arguments in function call
I am not allowed to use overloading operators at all to complete this task. What should I do to resolve this? Code has been abbreviated to show relevant parts. Thanks again.