Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class complexNum
  4. {
  5.  
  6. private:
  7.  
  8.     double w, i;
  9.  
  10. public:
  11.  
  12.     complexNum ();
  13.     complexNum (double, double);
  14.  
  15.     void add      (complexNum o)
  16.     {
  17.         w += o.getWholePart();
  18.         i += o.getImagiPart();
  19.     }
  20.     void subtract (complexNum o)
  21.     {
  22.         w -= o.getWholePart();
  23.         i -= o.getImagiPart();
  24.     }
  25.     void multiply (complexNum o)
  26.     {
  27.         w = w*o.getWholePart() - i*o.getImagiPart();
  28.         i = w*i + i*o.getWholePart();
  29.     }
  30.     void print(complexNum o)
  31.     {
  32.         std::cout << "blah";
  33.     }
  34.     double getWholePart ()
  35.     {
  36.         return w;
  37.     }
  38.     double getImagiPart ()
  39.     {
  40.         return i;
  41.     }
  42.     void print()
  43.     {
  44.         std :: cout << "(" << w << " + " << i<<"i)";
  45.     }
  46.  
  47.  
  48. };
  49.  
  50. complexNum::complexNum ()
  51. {
  52.     w = 16;
  53.     i = 12;
  54. }
  55.  
  56. complexNum::complexNum (double wPart, double iPart)
  57. {
  58.     w = wPart;
  59.     i = iPart;
  60. }
  61.  
  62. int main()
  63. {
  64.     double x1, y1, x2, y2;
  65.     std::cout << "Enter an x1 and y1 value in the form x1, y1";
  66.     std::cin >> x1 >> y1;
  67.     std::cout << "Enter an x2 and y2 value in the form x2, y2";
  68.     std::cin >> x2 >> y2;
  69.     complexNum.add;
  70.     a.print();
  71.     complexNum.subtract;
  72.     complexNum.multiply;
  73.  
  74.     system("PAUSE");
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement