constant Expressions (const expression): An expression that means that the value does not change and that the results are evaluated during compilation . (a constant expression cannot be a result of the run ).
const int i=3; is a constant expression
const int j=i+1; is a constant expression
int k=23; The value of K can be changed, thus not a constant expression
const int m=f (); is not a constant expression, the value of M is only obtained at run time.
constexpr Variables :
C++11 allows you to declare a constexpr type because the compiler verifies that the value of the variable is a constant expression. A constant must be declared as constexpr and can only be initialized with a constant or constant expression .
constexpr int i=3;
constexpr int j=i+1;
constexpr int k=f ();//Only F () is a constexpr function when k is a constant expression
In general, if the variable is a constant expression, declare it as a constexpr type
Constexpr and constant Expressions (c++11 standard)