Rule 18-4-1 (ban of dynamic heap memory allocation)

Moderators: david ward, misra cpp

Post Reply
shanz
Posts: 1
Joined: Fri Sep 26, 2008 2:04 pm
Company: Elekta

Rule 18-4-1 (ban of dynamic heap memory allocation)

Post by shanz » Mon Sep 29, 2008 10:28 am

One of the most commonly quoted advantages of object orientation is polymorphism.
C++ often relies on dynamically allocated pointers to achieve (run-time) polymorphism.

How can polymorphism be achieved without resorting to dynamic memory allocation?
I suspect that preallocating pointers on the stack is the answer but can someone please write some example code?

Thanks.

misra cpp
Posts: 151
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: Rule 18-4-1 (ban of dynamic heap memory allocation)

Post by misra cpp » Tue Oct 11, 2016 11:16 am

Polymorphism and the use of dynamic memory are not intrinsically linked, so polymorphism is possible without the use of dynamic memory
Posted by and on behalf of
the MISRA C++ Working Group

Post Reply

Return to “6.18 Language support library (C++)”