Dynamic object: – A class can be initiated at run time and objects created by such initialization are called dynamic object. The life time of dynamic objects in C++ is managed explicitly by the program. The program must grantee that each dynamic object is deleted when it is no longer needed and certainly before it becomes garbage. For each dynamic allocation, a policy that determines the object’s life time must be found by the programmer and implemented. These policies used in managing dynamic objects. The life time of an object in C++ is the interval of time it exist by occupying memory. Creation and deletion of object as and when required, offers a great degree of flexibility in programming.
Object with scope life time are created in stack memory. Stack memory is a store house which holds local variables or object and whenever they go out of scope, the memory allocated for them in the stack is released automatically. Object with arbitrary life time are created in the heap memory. These dynamic object can be created or destroyed as and when required, explicitly by the programmer. The operator new and delete is used with standard data type variable’s management can also be used for creating or destroyed objects at run time respectively.