Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by agasha ( 16 years ago )
#include <cstdlib>
#include <iostream>
// + -
// ++ -- pre i post
// = == !=

using namespace std;

class zespolone{

public: double re,im;
        zespolone()   {}
    
        zespolone(double a,double b){
          re=a; 
          im=b;
        }
        
        
        zespolone &operator;= (zespolone &b){ // srednik sam sie wstawia tutaj...
          if(&b!= this){
            re = b.re;
            im = b.im;                    
            return *this;
          } 
        }
  
  bool operator ==(zespolone b){
    if ((this->re==b.re) && (this->im==b.im)) return true; 
    else return false;
  }
  
  bool operator !=(zespolone b){
    if ((this->re!=b.re) && (this->im!=b.im)) return true; 
    else return false;
  }
        

};
      

ostream & operator <<(ostream & ekran, zespolone c){
  ekran << "LZ: " ;
  ekran << " (";
  ekran << c.re << " + " << c.im << "i"  << ")" ;
  return ekran;
}
   

int main(){ 
 
 zespolone a(1,2),b(3,4),z();
 
 cout << a << "  =  "  << b << "   ->   " ;
 //cout << a=b << endl << endl; //nie dziala
 // cout << a.operator=(b); // dziala
 cout << a << "  !=  "  << b << "   ->   " << a.operator!=(b) << endl << endl; // a!=b nie dziala
 cout << a << "  ==  "  << b << "   ->   " << a.operator==(b) << endl << endl; // a==b nie dziala
    system&#40;"PAUSE"&#41;;
    return EXIT_SUCCESS;
}

 

Revise this Paste

Parent: 14431
Children: 14433
Your Name: Code Language: