Articles to prepare
- 12Number of questions
- 265Test passed (times)
- 202Users who passed the test
- 59.283Average score
- --Your average score

C++ → C++ - Tutorial 003. Constants
C =++ supports two notations of immutability:
- const - which implies that the value will not change. First of all, this is used to specify interfaces, for data that is passed to functions and methods so that they are not afraid that they will be changed. The compiler monitors the presence of the const qualifier;
- constexp - which involves calculating the constant at compile time. Used to store data in memory where they will not be damaged, and to improve performance.
For example:
const int dmv = 17; // Constant with the name dmv int var = 17; // Var is not a constant constexpr double max1 = 1.4∗square(dmv); // OK, since square (17) is a constant expression constexpr double max2 = 1.4∗square(var); // Error, because var is not a constant const double max3 = 1.4∗square(var); // OK, because the expression can be evaluated in runtime double sum(const vector<double>&); // sum will not modify its arguments vector<double> v {1.2, 3.4, 4.5}; // v is not a constant const double s1 = sum(v); // OK, it will be calculated in runtime constexpr double s2 = sum(v); // Error, sum (v) is not a constant expression.
Timeweb
Let me recommend you the excellent hosting on which EVILEG is located.
For many years, Timeweb has been proving his stability.
For projects on Django I recommend VDS hosting
View Hosting