Let\'s consider this example.
class StaticlyManagedObject
{
//some class members....
}
class DynamiclyManagedObject
{
StaticlyManagedObject _staticlyManage
A subobject has the same storage duration as the complete object it is a part of. If an instance of DynamiclyManagedObject
is dynamically allocated, then the StaticlyManagedObject
member will be destroyed when the DynamiclyManagedObject
is destroyed.
Informally, you might say that the subobject will be on the heap if and only if the complete object is on the heap. However, storage duration is the technically correct way to talk about it; heap and stack are implementation details.