Advertisement
Adytzu04

l4p1 POO

Oct 29th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #ifndef L4P1_H
  2. #define L4P1_H
  3.  
  4. #include<iostream>
  5.  
  6. using namespace std;
  7.  
  8. class Complex
  9. {
  10.     int re, im;
  11. public:
  12.     Complex()
  13.     {
  14.         re=0;
  15.         im=0;
  16.     }
  17.  
  18.     Complex(int re, int im)
  19.     {
  20.         this->re = re;
  21.         this->im = im;
  22.     }
  23.  
  24.     int Complex::egal(Complex c2)
  25.     {  
  26.         if((this->re==c2.re)&&(this->im==c2.im))
  27.             return 1;
  28.         else
  29.             return 0;
  30.     }
  31.  
  32.  
  33.     void Complex::citire()
  34.     {      
  35.  
  36.         cout<<"Re=";
  37.         cin>>this->re;
  38.         cout<<"\nIm=";
  39.         cin>>this->im;
  40.     }
  41.  
  42. };
  43.  
  44.  
  45. #endif
  46.  
  47. //main
  48.  
  49. #include "l4p1.h"
  50.  
  51. int main()
  52. {
  53.     int x,b;
  54.     Complex c1,c2;
  55.     Complex c3(5,6);
  56.     c1.citire();
  57.  
  58.     c2.citire();
  59.    
  60.     x=c1.egal(c2);
  61.    
  62.     if(x==1)
  63.         cout<<"\nNumerele sunt egale"<<endl;
  64.     if(x==0)
  65.         cout<<"Numerele nu sunt egale";
  66.  
  67.     cin>>b;
  68.     return 0;
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement