// (C) Porkolab 2003 // // A.4.3. // // Creation and destruction An object can be created as: - named automatic object C - when declaration is encountered D - when the program exits the block, in reverse order - free store object C - new D - delete - nonstatic member object C - when the object which is created, in the order of declaration D - when the object is destroyed, in reverse order - array element C - when the array is created, in growing index order D - when the array is destroyed, in reverse order - local static object C - when first time the declaration is evaluated D - at the end of the program - global, namespace or class static object C - at the start of the program D - at the end of the program - temporary object C - created as part of the evaluation of an expression D - at the end of the full expression - placement new C - new D - delete - member of a union may not have constructor or destructor (the member) (a union also may not have static field) Free store: date *p = new date; date *q = new date(*p); date *s = new date[10]; delete p; delete p; // !! runtime error delete s; // !! runtime error