Results 1 to 4 of 4

Thread: Pointers and QLIst<int*> and stack and heap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    62
    Thanked 260 Times in 246 Posts

    Default Re: Pointers and QLIst<int*> and stack and heap

    QList<int*> name; name is a QList which contains pointers to int (note that no objects are created now).
    If you use it make sure you initialize the pointers, else you will get "seg fault" or "access violation"

    And if you allocate memory on the heap, you will need to delete those pointers (the list doesn't do that automatically***)

    ***for the types that can have parents and have a parent you don't need that since Qt has some memory management for QObjects see parent-child relationship in the documentation.


    Added after 37 minutes:


    Quote Originally Posted by mobucl View Post
    And also as i said below i note that you cant do:
    int* name
    Yes you can, it's the same as: int *name; //it's a matter of style if you put the '*' closer to the type, or closer to the pointer variable name, the compiler doesn't care.
    Last edited by Zlatomir; 12th February 2011 at 13:07.

Similar Threads

  1. Replies: 5
    Last Post: 20th April 2010, 17:48
  2. Replies: 5
    Last Post: 29th November 2009, 15:09
  3. 2 questions: QAuthenticator and stack / heap
    By Tito Serenti in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2009, 06:56
  4. QList Pointers
    By coderbob in forum Newbie
    Replies: 2
    Last Post: 20th November 2007, 18:50
  5. stack, heap and C#
    By mickey in forum General Programming
    Replies: 8
    Last Post: 20th August 2007, 18:40

Tags for this Thread

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.