Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>complex::operator</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
complex::operator

Usage

   #include <complex.hpp>

   // arithmetic:
   friend complex operator+(const complex&, const complex&);
   friend complex operator-(const complex&, const complex&);
   friend complex operator*(const complex&, const complex&);
   friend complex operator/(const complex&, const complex&);

   // relational:
   friend int operator&&(const complex&, const complex&);
   friend int operator||(const complex&, const complex&);
   friend int operator!=(const complex&, const complex&);
   friend int operator==(const complex&, const complex&);

   // assignment:
   complex& operator=(const complex&);
   complex& operator+=(const complex&);
   complex& operator-=(const complex&);
   complex& operator*=(const complex&);
   complex& operator/=(const complex&);

   // unary:

   int operator! () const;
   complex operator- () const;

   // streams:
   friend ostream& operator<<(ostream& s, const complex& x);
   friend istream& operator>>(istream& s, const complex& x);

Description

   The operators defined for class complex are overloaded to have an
   analogous meaning to built-in operators; i.e. "+" is the addition of two
   complex variables just as it is used for the addition of two variables of
   type double. The operators in the complex class maintain conventional
   operator precedence.

   The following summarizes the operators defined for the complex class. The
   variables z, z1 and z2 are of type complex. The variable i is of type
   int.

   Arithmetic

   z = z1 + z2 addition
   z = z1 - z2 subtraction
   z = -z1 negation
   z = z1 * z2 multiplication
   z = z1 / z2 division

   Relational

   i = z1 == z2    equality
   i = z1 && z2    logical AND
   i = z1 || z2    logical OR
   i = z1 != z2    inequality

   Assignment

   z1 = z2
   z1 += z2
   z1 -= z2
   z1 *= z2

   z1 /= z2

   Stream

   cout << z1  output to ostream in the form ( re, im).
   cin >> z1   input from istream of the form re im.

Example 

   #include <iostream.hpp>
   #include <stdlib.h>

   int main()
   {
       complex a(1,3), b(2,3);
       cout << a + b*5;
       return EXIT_SUCCESS;
   }

See Also

   Complex Class, operators, trigonometric functions, hyperbolic functions,
   complex functions, math functions





Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson