c++ - Why can't you use constexpr on variables declared but not defined in a function? -
I was reading through the C ++ Primer 5th Edition, and was confused about why the variable It is possible to use a constexpr pointer defined outside the function but not declared outside the function.
Is there a time when you define the function outside? It seems that you declare the function outside while using it again, but I'm not sure how many times the variable will be defined outside the function (unless the main is counted as a function in this case) .
Edit : Emphasis my
We will cover the reasons ... the defined variables inside the function are not stored at a certain address Are there. Therefore, we can not use such a variable using a constexp point. On the other hand, the address of the defined object outside any given task is continuous expression and it can be used to start a constexpr indicator is.
Comments
Post a Comment