SHARE
TWEET

Untitled

a guest Jun 20th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. class Bazna {
  3.  int p;
  4. public:
  5.  Bazna() : p(0) {}
  6.  virtual void f(int x) = 0;
  7.  virtual int g(int x) const { return x + 1; }
  8.  bool operator !(Bazna b) { return b.p != 0; }
  9.  Bazna &operator ++(Bazna &b) { b.p++; return *this; }
  10.  friend int operator ()(Bazna b, int x) { return b.p + x; }
  11.  void operator[](int x) { std::cout << p - x; }
  12. };
  13. class Izvedena : public Bazna {
  14.  int q;
  15. public:
  16.  Izvedena(int p, int q) : p(p), q(q) {}
  17.  void f(int x) override { (*this)[x]; }
  18.  virtual int g(int x) override { return x - 1; }
  19.  Izvedena operator --(int) { return Izvedena(p - 1, q - 1); }
  20. };
  21. int main() {
  22.  Bazna b; Izvedena i(3, 5);
  23.  Izvedena *p = new Izvedena[10];
  24.  ++b; --i; b[b(3)];
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top