Often when using arrays, it is handy to know the size of the array, and use that size multiple times in your C++ source-code.
To enhance readment and to also make it easy to let size grow or shrink in future, when requirements could change, often programmers use symbolic constants. This is an example of a symbolic constant:
const int ArSize = 20;
now everywhere in your program where you need to use the maximum size of your array, you simply use ArSize as shown next:
char name2[ArSize] = "C++owboy";
Simple as it sounds, I hope I won't forget this nice future :)
Abonneren op:
Reacties posten (Atom)
Geen opmerkingen:
Een reactie posten