Thread: using new/delete when building classes

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    17
    ok yes, I understand that. And the first one is on the stack, but isn't part of it on the heap?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    void SomeObject(int it)
    {
        InitObject(it);
    };
    Constructors/destructors do not have return types.

    Quote Originally Posted by zcot
    ok yes, I understand that. And the first one is on the stack, but isn't part of it on the heap?
    The SomeObject object (its member variables) is created on the stack. The memory allocated for use by its SomeThing and SomeItem members however comes from the heap.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    17
    Quote Originally Posted by hk_mp5kpdw
    Code:
    void SomeObject(int it)
    {
        InitObject(it);
    };
    Constructors/destructors do not have return types.
    Yes, thanks for pointing out that oversight. Obviously my cutNpaste when whipping that up was a bit out of hand.

    So....
    Is there a good and bad about this design?
    Is anybody looking at the function code in relation to memory management?

    Is anybody looking at the design?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM