Why do we use constexpr instead of writing the number in the string?

1 Like

Hello @Izan_Ahmed,

imagine you have several texts and you would try to change that number. Use a variable and change the value once. Then, in all texts the displayed message will also change.

This is much more handy instead of alter every number in form of string in each of the texts.

Kind regards
Kevin

Another really great explanation of why we use constatns is given by https://www.learncpp.com/cpp-tutorial/2-9-symbolic-constants-and-the-const-keyword/

1 Like

Privacy & Terms