#include <iostream.h>
class ulamek 
{
      private:
              int x,y;
      public:
             ulamek();
             ulamek(int x, int y=1);
             void wypisz();
             //void dodaj(ulamek b);
             //int licz() const;
             //int mian() const;
             //ulamek operator+(const ulamek &b);
             ulamek operator++();
             ulamek operator++(int);                       
};

ulamek::ulamek()
{
       x=1;
       y=5;
}
ulamek::ulamek(int a, int b) :x(a),y(b)
{
    if (y == 0) 
    {
          cout<<"Bledny mianownik!"<<endl;
          y=1;
    }   
}

void ulamek::wypisz()
{
 cout<<x<<"/"<<y<<endl;
}

/*
void ulamek::dodaj(ulamek b)
{
       x=x*b.y+b.x*y;
       y=y*b.y;
}

ulamek ulamek::operator+(const ulamek &b)
{
       return ulamek(x*b.y+b.x*y,y*b.y);
}

int ulamek::licz() const
{
    return x;
}
int ulamek::mian() const
{
    return y;
}

ulamek operator+(const ulamek &a, const ulamek &b)
{
       cout<<"Suma ulamkow: ";
       return ulamek(a.licz()*b.mian()+b.licz()*a.mian(),a.mian()*b.mian());
}
*/

ulamek ulamek::operator++() //preinkrementacja
{
       this->x=x+y;
       this->y=y;
       return *this;      
}

ulamek ulamek::operator++(int) //postinkrementacja
{
   ulamek temp = *this;
   ++*this;
   return temp;
}

int main()
{
    ulamek a;
    cout<<"Wartosc ulamka a przed post- i preinkrementacja: "; a.wypisz();
    cout<<"Preinkrementacja: ";
    ulamek f=++a;
    f.wypisz(); cout<<"Tymczasem a ma wartosc: "; a.wypisz();
    cout<<"Postinkrementacja: ";
    ulamek g=a++;
    g.wypisz(); cout<<"Tymczasem a ma wartosc: "; a.wypisz();
    system("pause>nul");
    return 0;
}
