ComplexNum

Hi guyz i have found some class of Complex Num here but i Cant understand some lines can u hel pme

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class complex
{
     private:
	 		float real;      // Real Part                      
			float imag;      //  Imaginary Part


   public:
          complex(float,float);					
          complex(const complex&);
          complex operator +(complex);
          complex operator -(complex);
          complex operator *(complex);
          complex operator /(complex);
          complex getconjugate();
          complex getreciprocal();
          float getmodulus();
          void setdata(float,float);
          void getdata();
          float getreal();
          float getimaginary();
          bool operator ==(complex);
          void operator =(complex);
          friend ostream& operator <<(ostream &s,complex &c);
};


Help me to understand members of public expect of operators.
Last edited on
What lines do you not understand?

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Oh nice. So i need 10 line why const and from 15 to 24 if u can. Thank forward
Line 10: is a copy constructor. const is used for the argument since the copy constructor does not change the argument.

For the following lines, I am presuming what the functions do from their names since the class declaration is not documented.

Line 15: Returns the conjugate of a complex number.
https://en.wikipedia.org/wiki/Complex_conjugate

Line 16: Returns a complex number that is the reciprocal of a complex number.

Line 17: Returns a modulus (absolute value) of a complex number.

Line 18: Sets the real and imaginary parts of a complex number.

Line 19: No idea what this does. Perhaps it prompts the user to enter the real and imaginary parts of a complex number.

Line 20: Returns the real portion of a complex number.

Line 21: Returns the imaginary part of a complex number.

Line 22: Compares 2 complex numbers.

Line 23: Assigns one complex number to another.

Line 24: Formats a complex number to an output stream.
Last edited on
Oh deepest thank you
Topic archived. No new replies allowed.