Summary
In this chapter, we have learned many aspects surrounding pointers in C++. We have seen how to allocate memory from the heap using new()
and how to relinquish that memory to the heap management facility using delete()
. We have seen examples using both standard and user defined types. We have also understood why we may want to dynamically allocate arrays and have seen how to do so for 1
, 2
, and N
dimensions. We have seen how to release the corresponding memory using delete[]
. We have reviewed functions by adding pointers as parameters to functions and as return values from functions. We have also learned how to const
qualify pointers as well as the data to which they point (or both) and why you may want to do so. We have seen one way to genericize pointers by introducing void pointers. Lastly, we have looked ahead to the concept of smart pointers.
All of the skills using pointers from this chapter will be used freely in the upcoming chapters. C++ expects programmers to have...