Re: C++ Question

From: Mr Hand (mrhand_at_gnarily.com)
Date: 03/11/05


Date: Fri, 11 Mar 2005 01:29:38 -0400

On 10 Mar 2005 02:28:08 -0800, consultant_image@yahoo.com
(ImageConsultant) wrote:

>Please give the ans. to the following question :-
> Q 1 Write a class which always allocate memory to its objects from heap only?

Why?

If you feel the class has too big a sizeof() to put on the stack then
just include that information in the documentation.

Otherwise there is no difference if an object is allocated on the heap
or in the stack.



Relevant Pages

  • Re: prefast "stack hog" warning for newed array
    ... Consider moving some data to heap. ... > Does not new allocate memory from the heap? ... > the stack then wouldn't a new'd object be lost when the function ... new allocates from the heap and this warning is bogus. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: C++ Question
    ... ImageConsultant wrote: ... > Q 1 Write a class which always allocate memory to its objects from heap ... we expect an initial posting to be a C++ question. ...
    (comp.lang.cpp)
  • Re: stack questions
    ... platform specific caveat to this since the documentation does not suggest ... Unless you are overflowing the stack, ... allocate memory outside the stack space? ... Yes, malloc allocates memory on the heap, not the stack (this is exactly how ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: How does managed code work?
    ... Does it work the same way as the native stack with a frame pointer that is the head of a linked list of stack frames where each time we enter a function we create a new stack frame in which new variables are pushed and each time we exit a function the entire stack frame is popped? ... Can someone point me to a discussion of the managed heap? ... How does it prevent memory leaks that occur in COM when two objects reference each other and keep the others reference count nonzero? ... Because objects don't go out of scope, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Groovy (war Re: [PROST]Re: CDC Plugin fuer Eclipse)
    ... Warum müsste man continuations erlauben Stackvariablen in den Heap zu verschieben? ... Ein activation record speichert die Parameter und lokalen Variablen der Funktion und eine Information, ... Da diese activation records klassischerweise auf einem Stack verwaltet werden, kann man hier Stackspace sparen - Endrekursion ist damit genauso effizient wie eine klassische Iteration mit einem Sprung. ...
    (de.comp.lang.java)