CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2002
    Location
    India
    Posts
    26

    Stack and Heap problem

    How to know a variable is defined on to stack or heap. Is Win OS providing any API to know it.

  2. #2
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    You could create a class and override operator new() to set a flag when something is created on the heap.

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Stack and Heap problem

    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

  4. #4
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    Maybe he is trying to create an auto-deleter like CException.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured