Enjoying C++: user allocation structures

  • Authors:
  • W. Douglas Maurer

  • Affiliations:
  • Department of Computer Science, The George Washington University, Washington, DC

  • Venue:
  • Proceedings of the seventh annual consortium for computing in small colleges central plains conference on The journal of computing in small colleges
  • Year:
  • 2001

Quantified Score

Hi-index 0.00

Visualization

Abstract

We are concerned here with what, to us, is the single most exciting feature of C++, and we wish to promulgate it to as many students as possible. This is the possibility of constructing user allocation structures through overloaded new and delete. We first take up the general allocation problem and show how Lisp, Pascal, Snobol 4, Ada, and C attempted to solve this problem. We then show how C++, alone among major languages, provides a straightforward way of setting up an allocation structure for each data structure, with a consequent improvement in allocation and deallocation efficiency. We provide a complete worked example involving linked lists, and then extend this to string classes, linked lists of strings, stacks, queues, trees, doubly linked lists, sparse matrices, polymorphic structures, and resizable structures. We also show how free storage can be expandable, starting with none; how a list of available space can be buffered, thus saving space; and how templates interact with all of the above techniques.