Why do I need to have this pointer as an attribute?

  1. int *mem; is the pointer to the contents of Staticarray
  2. You should allocate enough memory to hold the contents e.g. mem = new int[size];
  3. remember to delete mem at the destructor of Staticarray e.g. delete[] mem;
  4. To access the ith element of a Staticarray object called arr you would use arr.mem[i];

Leave a Comment