Content restrictions for a CPad
C++ objects of type class, struct, or union can be divided into
two groups:
- aggregate
- An aggregate is a class, struct, or union with no constructors, no private or protected members, no base classes, and no virtual functions. An aggregate can have static member functions and static class members.
- non-aggregate
- A non-aggregate is a class, struct, or union with at least one constructor, private or protected member, base class, or virtual function.
A CPad cannot be used to store a non-aggregate class that has a base class or a virtual method. This has particular implications for destructors on objects. Non-virtual destructors on objects are useful only if you manually invoke PAD_DELETE on an object and want the object to invoke PAD_DELETE on its children. (No heap memory that is used by the object or its children can be allocated by using anything other than PAD_NEW.)
When the object is destroyed automatically after the transaction, the destructor is not invoked, but the child objects are freed automatically to avoid a memory leak.