C++ Question

Discussion in 'C++' started by ImageConsultant, Mar 10, 2005.

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

    Warms Regards,
    Madhur Sharma
    ImageConsultant, Mar 10, 2005
    #1
    1. Advertising

  2. ImageConsultant

    Rolf Magnus Guest

    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?


    This is not a question, it is an assignment. Looks like homework to me. The
    deal is to show us what you have and what doesn't seem to work, and we give
    you advice on how to make it work.

    PS: Next time, you should be a bit more specific in your subject line. In
    this newsgroup, we expect an initial posting to be a C++ question. That's
    what comp.lang.c++ is all about.
    Rolf Magnus, Mar 10, 2005
    #2
    1. Advertising

  3. ImageConsultant

    Phil Staite Guest

    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?


    Here's a hint - consider hiding the constructor(s) and providing a
    static method to generate an instance...
    Phil Staite, Mar 11, 2005
    #3
  4. ImageConsultant

    Mr Hand Guest

    On 10 Mar 2005 02:28:08 -0800,
    (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.
    Mr Hand, Mar 11, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sean
    Replies:
    1
    Views:
    568
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    626
    Iain Norman
    Feb 16, 2005
  3. =?Utf-8?B?YW5kcmV3MDA3?=

    question row filter (more of sql query question)

    =?Utf-8?B?YW5kcmV3MDA3?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    923
    Scott Allen
    Oct 6, 2005
  4. Philip Meyer
    Replies:
    0
    Views:
    400
    Philip Meyer
    Nov 30, 2003
  5. Bit Byte
    Replies:
    1
    Views:
    813
    Teemu Keiski
    Jan 28, 2007
Loading...

Share This Page