Advertisement
tomasaccini

Untitled

Jul 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Complejo {
  4. public:
  5.     double real;
  6.     double imaginaria;
  7.  
  8.     Complejo() {
  9.         this->real = 0;
  10.         this->imaginaria = 0;
  11.     }
  12.  
  13.     Complejo(double real, double imaginaria) {
  14.         this->real = real;
  15.         this->imaginaria = imaginaria;
  16.     }
  17.  
  18.     Complejo(const Complejo& other) {
  19.         this->real = other.real;
  20.         this->imaginaria = other.imaginaria;
  21.     }
  22.  
  23.     Complejo& operator =(const Complejo& other) {
  24.         if (*this == other) return *this;
  25.         this->real = other.real;
  26.         this->imaginaria = other.imaginaria;
  27.         return *this;
  28.     }
  29.  
  30.     bool operator < (const Complejo& other) const {
  31.         return (this->real < other.real);
  32.     }
  33.  
  34.     bool operator > (const Complejo& other) const {
  35.         return (this->real > other.real);
  36.     }
  37.  
  38.     bool operator == (const Complejo& other) const {
  39.         return (this->real == other.real) && (this->imaginaria == other.imaginaria);
  40.     }
  41.  
  42.     operator int() const {
  43.         return (int)this->real;
  44.     }
  45.  
  46.     //Prefix
  47.     Complejo& operator ++(void) {
  48.         ++this->real;
  49.         ++this->imaginaria;
  50.         return *this;
  51.     }
  52.  
  53.     //Posfix
  54.     Complejo operator ++(int) {
  55.         Complejo temp = *this;
  56.         ++this->real;
  57.         ++this->imaginaria;
  58.         return temp;
  59.     }
  60.  
  61.     // Shift
  62.     Complejo operator <<(unsigned int shift) {
  63.         Complejo temp = *this;
  64.         // temp.real << shift;
  65.         // temp.imaginaria << shift;
  66.         return temp;
  67.     }
  68.     Complejo operator >>(unsigned int shift){
  69.         Complejo temp = *this;
  70.         // temp.real >> shift;
  71.         // temp.imaginaria >> shift;
  72.         return temp;
  73.     }
  74.  
  75.     friend std::ostream& operator << (std::ostream& o, const Complejo& complejo);
  76. };
  77.  
  78. std::ostream& operator << (std::ostream& o, const Complejo& complejo) {
  79.     o << "(" << complejo.real << ", " << complejo.imaginaria << ")";
  80.     return o;
  81. }
  82.  
  83. int main() {
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement