class Array {   public:      Array(int def = 0) {         m_array = NULL;         m_def = def;         m_size = m_length = 0;      }      ~Array() {         Free();      }      void Free() {         if(m_array != NULL) {             free(m_array);             m_array = NULL;         }         m_size = m_length = 0;      }      unsigned int Length() const {         return m_length;      }      unsigned int Size() const {         return m_size;      }      void Push(int e) {          if(m_length == m_size) {             unsigned int size = m_size ? m_size * 2 : 8;             if(m_array == NULL) {                m_array = (int *)malloc(size);                memset(m_array, m_def, size);             } else {                m_array = (int *)realloc(m_array, size);                memset(m_array+m_size, m_def, size-m_size);             }             m_size = size;          }          m_array[m_length++] = e;                }      int At(undigned int idx) const {         if(idx < m_size) return m_array[idx];         else return m_def;      }  protected:     int m_def;     unsigned int m_size, m_length;     int *m_array; }; int main(int argc, char *argv[]) {   Array a;   a.Push(1);   a.Push(2);   a.Push(6);   for(unsigned int i = 0; i < a.Length(); i++)      printf("%i: %i\n", i, a.At(i));   return 0; }