|
-
May 20th, 2008, 01:42 AM
#1
Add complex number using new and delete operator
Hi All,
I am learning c++, i am facing one problem adding the two objects , please help me How can i proced??
---------------------Code -------------------------------------------------------------------
#include<iosteream>
Using namespace std;
class Complex
{
double Real, imag;
public:
Complex()
{
Real = 0;
imag = 0;
}
Complex(double);
Complex(double, double);
};
void Complex : isplay()
{
cout << Real << "+i" << imag << "\n" ;;
}
Complex ::Complex(double aa)
{
Real = aa;
imag = 0;
}
Complex :: Complex( double aa, double bb)
{
Real = aa;
imag = bb;
}
void main()
{
Complex *p = NULL;
Complex *a = new Complex(2, 4);
Complex *b = new Complex(2, 4);
a->display();
b->display();
//p = a->operator +(b); // Here i am trying to add the complex number ??
}
Please how can add a and b complex number.
Thanks,
Anand
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|