Lecture overview -- Keyboard shortcut: 'u'  Previous page: Vectors - examples -- Keyboard shortcut: 'p'  Next page: Input and output in C++ -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 30 : 42
Notes about C++
Basic facilities
The free store

  • The C++ Programming Language: Page 127
 

The C++ operators new and delete are used instead of the <cstdlib> functions malloc / calloc and free

  • new

    • Application: new T, where T is a type

    • Returns a pointer to the new object

    • The object allocated by new lives until it is deallocated with delete

    • new returns a pointer to uninizialized memory

  • delete

    • Application: delete pT where pT is a pointer returned by new

    • A variant delete[] pT must be used if pT is a pointer to an array allocated by new

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/new-del.cppIllustration of free store.


"A C++ implementation does not guarantee the prescence of a 'garbage collector'" [Stoustrup page 128]