| |||||||||||
|
Main Menu Other |
Intro to Constants | ||||||||||
|
Quick Intro to ConstantsSay you have multiple settings for a value and you want to keep track of them. Using character strings is a bit more work than you want to handle, and remembering numbers for each setting is a pain. So what's the easy solution? Constants! You can declare a "constant" any way you'd like, but the common method is to use ALL_CAPS_AND_UNDERSCORES. All constants resemble that format. Also, most start off with the first letter of each word that describes what the constant is for. Like for DirectInput Keyboard constants, they look like DIK_PGDN or DIK_PGUP. To declare a constant, simply define them as integers. Do this at the beginning of your program, or preferably in a header file. You can set them to a "const int" to keep them permanent, or if you want to set them later (like by getting the return value of a function) just use plain "int". Read on for more about declaring constants and how you can use them.
|
|||||||||||