Results 1 to 7 of 7

Thread: what is free store in C++ memory?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: what is free store in C++ memory?

    Quote Originally Posted by Masih View Post
    how can a pointer exist but doesn't point to anything?
    Suppose somebody gave you a book and asked you to read page 1234. You open the book and see that there is no such page in that particular book, yet the page number exists.

  2. The following user says thank you to jacek for this useful post:

    Masih (4th June 2007)

  3. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: what is free store in C++ memory?

    Quote Originally Posted by jacek View Post
    Suppose somebody gave you a book and asked you to read page 1234. You open the book and see that there is no such page in that particular book, yet the page number exists.
    Yes, this is the best analogy so far.

    A pointer is just like a normal variable, but it's contents, instead of a value that you can normally use in your program, are a memory address of, let's say another variable.

    If the memory at that address has been deallocated, then your pointer still exists, but it does not point to anything( anything valid ).

    So it is no magic going on here. It's a about understanding what a pointer really is.
    Regards

  4. The following user says thank you to marcel for this useful post:

    Masih (4th June 2007)

  5. #3
    Join Date
    Apr 2007
    Posts
    33
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    21

    Arrow Re: what is free store in C++ memory?

    I've recently seen another explanation from this book : " An introduction to design patterns in C++ with Qt4" by Ezust & Ezust .
    Wanted to post it here

    Zero (0), often represented by the macro NULL in C programs, is a special value that can be legally assigned to a pointer, usually when it is being initialized (or re-initialized). 0 is not the address of any object. A pointer that stores the value 0 is called a null pointer. Stroustrup recommends the use of 0 rather than the macro NULL in C++ programs.

Similar Threads

  1. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42
  2. Replies: 2
    Last Post: 13th February 2006, 15:42

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.