How to know a variable is defined on to stack or heap. Is Win OS providing any API to know it.
Printable View
How to know a variable is defined on to stack or heap. Is Win OS providing any API to know it.
You could create a class and override operator new() to set a flag when something is created on the heap.
There is no standard way to determine if a variable is created on the heap or the stack, and there is no Windows API to guarantee this..Quote:
Originally posted by Saurabh Gupta
How to know a variable is defined on to stack or heap. Is Win OS providing any API to know it.
Having to know if a variable is created on the stack or heap sounds like a design flaw. If you can tell us what you're trying to accomplish, maybe someone can suggest alternatives.
Regards,
Paul McKenzie
Maybe he is trying to create an auto-deleter like CException.