Why use static when you are already in an anonymous namespace?
I see no reason for this if it is not written for compatibility with C ++ 03.
Why use constexpr - there is no reason to use it here. won't a simple const work?
Again, this is not necessary, but this indicates that it is a compile-time constant. Also note that constexpr here means that the pointer is constexpr , and eliminates the need for const after * (see the next part).
const *Hello doesn't make sense to me. What is always here? String or pointer * Hello?
const applies to left if there is nothing there, in which case it applies to right. const left of * means that the pointer is a constant when dereferenced, and to the right means that it is a constant pointer to something.
char const * ptr = "Foo"; ptr[0] = 'B'; //error, ptr[0] is const char * const ptr = "Foo"; ptr = new char[10]; //error, ptr is const char const * const ptr = "Foo"; //cannot assign to either ptr or *ptr constexpr char const* ptr = "Foo"; //same as above, constexpr replaced last const
I found that this page in the "right" rule really helps with understanding complex ads.
James root
source share