/* * This class provides a skeletal IntArrayList object with only constructors * for the purposes of memory diagrams in wrapmain.cc. * * Warning: This code is incomplete and leaks memory! */ #define MAXSIZE 3 #include #include class IntArrayList { public: IntArrayList() : array_(new int[MAXSIZE]), len_(0), maxsize_(MAXSIZE) { } IntArrayList(const int *const arr, size_t len) : len_(len), maxsize_(len_*2) { array_ = new int[maxsize_]; memcpy(array_, arr, len * sizeof(int)); } IntArrayList(const IntArrayList &rhs) { len_ = rhs.len_; maxsize_ = rhs.maxsize_; array_ = new int[maxsize_]; memcpy(array_, rhs.array_, maxsize_ * sizeof(int)); } private: int *array_; size_t len_; size_t maxsize_; };