arraystack.cpp contains an implementation of ArrayStacks. A few points:
vector
and it is described at the end of Chpater 2 of TICPP. All actual C++ code which needs a list ADT should use vectors! I am showing this implementation of ArrayStacks just as an example, you should never use this code.vector
does so), but we haven't learned that yet and at the moment I just want to focus on implementing ArrayStacks in C++.assert
to make sure the index passed to get
, set
, and add
are within range. This will crash the program with a message if the assert is invalid (try it out!). This is fine for this simple demonstration, but in a real program you would want to use exceptions so that the program does not just crash.No specific exercises today, just complete the exercises from last time on pointers.