C++ Tips: Constructor/Destructor


Table of Contents


Initialization

Order of construction/destruction of static global objects
Initialization of global objects
Ensuring global object initialization
Bad global object initialization schemes
Bad global object initialization schemes
Example of bad assumptions in initialization ordering
Initialization of global objects
Initialization of global data
initializing built-in arrays
a little initialization gem
nested structures initialization

Construction

Auto type conversion selects surprising constructor
Constructor calls with virtual base classes
Initialization order of members
What do constructors return?
New definition of default constructor
Virtual base class construction order
Placement new operator
Determining constructors at run-time
exit(), exec(), and fork()
What does "virtual constructor" mean?
Inlining, constructors, and CFront
Construction versus initialization
Another implementation of "virtual constructors"
Size argument to X::new() may not be equal to sizeof(X)
Type-ids, temporaries, and static variable constructors
To be or not to be (inlining constructors)
Initialization order of globals
Why is virtual base class initialization the way it is?
Trying to take the address of constructors
trivial constructor
ctor, __ct, constructor
self assignment within constructors
calling the most virtual method during construction
using "this" too early?
direct and copy initialization
virtual functions in constructors
contructor failures
distinguishing constructors with artificial types
explicit constructor call of virtual base class

Both

Calling virtual methods from within constructors/destructors
Tuned, class-specific operator new and delete
The cost of inlining con/destructors
explicitely invoking con/destructors
type signatures for new and delete

Destruction

Deleting "this"
Destructor invocation upon exit
Calling delete on a NULL pointer
Delete syntax and arrays of built-in types
Explicit destructor calls
Dynamic binding and deleting arrays of objects
Thoughts on delete and zeroing pointers
Calling destructors directly
Deleting a void pointer
Using delete []
versus delete

Size argument to X::delete() may be surprising
Delete operator versus operator delete
Why use virtual destructors (let me count the ways)
Why virtual destructors?
Pure virtual destructors
destructors for built-in types
is "delete this" safe
why pure virtual destructors
destructor design error is now undefined behavior
why have virtual destructors
destruction through base pointers with no virtualness
destructors for built-in types
delete of an opaque type
termination in the DWP (Draft C++ Working Paper)
rule-of-thumb: using virtual destructors
invoking the placement delete operator
reasons for allowing delete of incomplete types
initializer and no arg constructor syntax
base class pointer deletion sometimes undefined
destruction and program exit
deletion of incomplete types
pure virtual destructors - a summary

This site was grabbed using the TRIAL version of Grab-a-Site. This message does not appear on a licensed copy of Grab-a-Site.