/** 
 * Draw the memory diagram at each statement executed.
 * Warning: this code is buggy! 
 */

#include <cstdlib>
#include "./IntArrayList.h"

class Wrap {
  public:
    Wrap() : p_(nullptr) {}
    Wrap(IntArrayList *p) : p_(p) { *p_ = *p; }
    IntArrayList *p() const { return p_; }
  private:
    IntArrayList *p_;
};

struct List {
  IntArrayList v;
};

int main() {
  Wrap a;
  Wrap b(new IntArrayList); 
  struct List c { }; 
  struct List d { *b.p() }; 
  a = b;  
  c = d;  
  Wrap *e;
  e = &a; 
  Wrap *f = new Wrap(&d.v); 
  struct List *g = new struct List; 
  g->v = *(new IntArrayList);
  delete f;
  delete g;
  return 0;
}