guides:programstyle:constants
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| guides:programstyle:constants [2020/07/24 12:08] – wikiadmin | guides:programstyle:constants [2022/08/02 11:59] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 57: | Line 57: | ||
| * TWENTY is no more informative than 20. | * TWENTY is no more informative than 20. | ||
| * If the value of the constant changed, the programmer might be tempted to produce the following totally unacceptable code | * If the value of the constant changed, the programmer might be tempted to produce the following totally unacceptable code | ||
| - | | + | |
| const int TWENTY = 35; | const int TWENTY = 35; | ||
| </ | </ | ||
| - | Unless otherwise instructed, | + | Unless otherwise instructed, single |
| + | |||
| + | The following is probably not necessairy | ||
| + | <code c++> | ||
| + | const int FIRST_FIELD_WITDTH = 20; | ||
| + | const string FIRST_PROMPT = "Enter your Age"; | ||
| + | ... | ||
| + | |||
| + | cout << setw(FIRST_FIELD_WIDTH) << FIRST_PROMPT << endl; | ||
| + | </ | ||
guides/programstyle/constants.1595592506.txt.gz · Last modified: 2022/08/02 11:59 (external edit)