Unsolved 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 ?
-
Hi,
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 asusing cpWidget = const Widget*
and thenconst cpWidget&
.
Having said that it's not very useful as a construct given pointers and references occupy the same amount of memory soconst Widget* const
would have been identical