Chapter 12. New and Delete

    FAQ 12.01 Does new do more than allocate memory?

    FAQ 12.02 Why is new better than good old trustworthy malloc()?

    FAQ 12.03 Does C++ have a counterpart to realloc() that goes along with new and delete?

    FAQ 12.04 Can pointers returned from new be deallocated with free()? Can pointers returned from malloc() be deallocated with delete?

    FAQ 12.05 Does delete p delete the pointer p or the referent *p?

    FAQ 12.06 Should the pointer returned from new Fred() be checked to see if it is NULL?

    FAQ 12.07 How can new be convinced to return NULL rather than throw an exception?

    FAQ 12.08 How can new be set up to automatically flush pools of recycled objects whenever memory runs low?

    FAQ 12.09 What happens if delete p is called when p is NULL?

    FAQ 12.10 What happens when a pointer is deleted twice?

    FAQ 12.11 How can an array of things be allocated and deallocated?

    FAQ 12.12 What if delete p (not delete[] p) is used to delete an array allocated via new Fred[n]?

    FAQ 12.13 Can the [] of delete[] p be dropped when p points to an array of some built-in type such as char?

    FAQ 12.14 How is an object constructed at a predetermined position in memory?

    FAQ 12.15 How can class Fred guarantee that Fred objects are created only with new and not on the stack?

    FAQ 12.16 How are objects created by placement new destroyed?

    FAQ 12.17 In p = new Fred(), does the Fred memory "leak" if the Fred constructor throws an exception?

    FAQ 12.18 Is it legal (and moral) for a member function to say delete this?

    FAQ 12.19 After p = new Fred[n], how does the compiler know that there are n objects to be destructed during delete[] p?



C++ FAQs
C Programming FAQs: Frequently Asked Questions
ISBN: 0201845199
EAN: 2147483647
Year: 2005
Pages: 566
Authors: Steve Summit

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net