Results 1 to 13 of 13

Thread: Why const can disappear at QMap::value(...)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why const can disappear at QMap::value(...)

    Quote Originally Posted by d_stranz View Post
    Even after 25+ years of C++ coding, this is one aspect that continues to confuse me. And then there are the versions with two const declarations "const MyObject const *" or whatever. Thank god for google.
    C/C++ is quite liberal with the placement of the "const" qualifier in a declarator. IMHO it is a shame that the ambiguous form "const T *" be so prevalent. I tend to consistently place "const" after the type it qualifies, like * and &, which eliminates the ambiguous forms. All I have to do is read the declaration from right to left:
    T const: constant T
    T const *: pointer to constant T
    T * const: constant pointer to T
    T const * const: constant pointer to constant T

    If you ever are in doubt about a declaration, check out the excellent cdecl.org.

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

    d_stranz (19th December 2015)

Similar Threads

  1. Replies: 0
    Last Post: 22nd June 2013, 10:02
  2. screen just disappear after compiling
    By calebmakore in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2011, 08:20
  3. Can't get title bar to disappear from widget
    By MattPhillips in forum Qt Programming
    Replies: 11
    Last Post: 2nd November 2010, 14:41
  4. Replies: 1
    Last Post: 4th December 2009, 17:03
  5. const member and const method
    By mickey in forum General Programming
    Replies: 8
    Last Post: 9th April 2008, 09:44

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.