Results 1 to 9 of 9

Thread: What do you prefer: dynamically or statically create objects?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Apr 2007
    Posts
    10
    Thanks
    3

    Default Re: What do you prefer: dynamically or statically create objects?

    Quote Originally Posted by high_flyer View Post
    But you are using the wrong assumption.
    Stack allocated memory lives in the scope it is created.
    I meant declaring them as class members. If they live during all class life, I didn't see the problem of being statically allocated.

    Quote Originally Posted by wysota
    Yes, there is a reason. You can't allocate a widget that has a parent on the stack unless you make sure the child is destroyed before the parent. Otherwise the parent will delete the child and then the compiler will try to delete it again when going out of scope and the application will crash.
    But if it's a statically allocated widget, it doesn't need to be created with a parent, right?

    Anyway, the point of the stack being limited is enough to allocate widgets on the heap.

    Thanks to both by your replies
    Last edited by IrYoKu; 18th April 2007 at 16:38.

Similar Threads

  1. dynamically create folders with QT
    By eleanor in forum Newbie
    Replies: 3
    Last Post: 13th March 2007, 11:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.