Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. class Widget const * const &

class Widget const * const &

Scheduled Pinned Locked Moved Unsolved C++ Gurus
3 Posts 3 Posters 452 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vinoth Rajendran4
    wrote on last edited by
    #1

    Hi All,
    I know it's not the proper way to ask questions, but i don't have reference material to suport my question,

    What this really means

    class Widget const * const &
    

    I have seen this code somewhere , not sure where....

    Can someone please help me understand what this stands for ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, this is just wrong. You either forward declare a class or you create one but that line is not valid C++.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        I think it might be a valid template parameter, like template <class Widget const * const &> void doSomething();
        In any case, const refers to the item on its left unless it has nothing on its left so it refers to the item on it's right. Then you start reading right to left. In your case it's a reference to a const pointer to a const widget.
        You can imagine it as using cpWidget = const Widget* and then const cpWidget&.
        Having said that it's not very useful as a construct given pointers and references occupy the same amount of memory so const Widget* const would have been identical

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved