Re: Passing more than 1 param in AfxBeginThread

From: Dazz (anonymous_at_discussions.microsoft.com)
Date: 05/19/04


Date: Wed, 19 May 2004 08:26:05 -0700

Thanks Joe,

I have a question about your solution. what is the difference between declaring the the pointer *p on the heap and then deleting after finishing with it, and just declaring it on the stack?

class Parameters {
    public:
          int x;
          int y;
          CWnd * wnd;
};

Parameters *p;
p->x = ...
p-> = ...
p->wnd = this;
AfxBeginThread(thread, p);

What i want to know is when should i declare a var on the heap instead of on the stack?

i.e
CClass *p = new (CClass) against CClass *p

cheers
Dazz



Relevant Pages

  • Re: How to allocate new class instance on the heap?
    ... >This will allocate ClassInstanceVariable on the heap, ... >automatically deallocate it when the function declaring ...
    (comp.lang.pascal.delphi.misc)
  • Re: Creating member vars on the heap, not the stack
    ... on the heap, not the stack. ... Other than declaring all the members of the class as static, ...
    (microsoft.public.vc.language)
  • Re: Passing more than 1 param in AfxBeginThread
    ... what is the difference between declaring the the pointer *p on the heap and then deleting after finishing with it, and just declaring it on the stack? ... If you declare a variable on the stack it disappears when the function ...
    (microsoft.public.vc.mfc)
  • Re: dot net and stack
    ... allocated from stack - as opposed to from the heap. ... field, say, of value type is stored within the object BLOB. ... I suspect the author just did not consider the possibility of declaring a value variable in a module, but not in a class or procedure. ...
    (borland.public.delphi.non-technical)
  • Re: FindFirstFile Possible Memory Leak
    ... It's interesting what you say about adding to the stack during ... Declaring all variables at the top is an artifact of how programming ... instructions were setup. ... Interpreted languages were not quite so constrained as their only ...
    (microsoft.public.vb.general.discussion)