Qt World Summit: Submit your Presentation

class Widget const * const &

  • 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 ?

  • Lifetime Qt Champion


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

  • 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

Log in to reply