Click to See Complete Forum and Search --> : Stack and Heap problem


Saurabh Gupta
April 15th, 2003, 06:53 AM
How to know a variable is defined on to stack or heap. Is Win OS providing any API to know it.

mwilliamson
April 15th, 2003, 09:40 AM
You could create a class and override operator new() to set a flag when something is created on the heap.

Paul McKenzie
April 15th, 2003, 10:29 AM
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. 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..

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

mwilliamson
April 15th, 2003, 02:22 PM
Maybe he is trying to create an auto-deleter like CException.