Results 1 to 7 of 7

Thread: Pointers: NULL vs. 0

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 69 Times in 67 Posts

    Default Re: Pointers: NULL vs. 0

    No it doesn't matter. A pointer is in the end just an integer. The null pointer can either be:
    Qt Code:
    1. #define NULL 0
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. #define NULL ((void *)0)
    To copy to clipboard, switch view to plain text mode 

    More often than not, the former is used.

    In the C++0x standard that is still in the making, plans are to deprecate the above definitions and introduce a null pointer called nullptr_t, to prevent the following confusion:
    Qt Code:
    1. void func(int i);
    2. void func(const char *t);
    To copy to clipboard, switch view to plain text mode 
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

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

    hackerNovitiate (31st January 2010)

Similar Threads

  1. setRelation and NULL in ID
    By Auryn in forum Qt Programming
    Replies: 4
    Last Post: 26th May 2015, 16:20
  2. Null for QDateEdit
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2009, 21:54
  3. QPixmap seems to be null but it isn't
    By satoshi in forum Qt Programming
    Replies: 7
    Last Post: 8th May 2009, 09:23
  4. QSqlTableModel and NULL
    By karas in forum Qt Programming
    Replies: 0
    Last Post: 9th February 2009, 12:55
  5. checking for null
    By drkbkr in forum General Programming
    Replies: 6
    Last Post: 13th March 2006, 21:54

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.