You Like My Tutorials? Click The Banner To Keep 'Em Coming!

glGameDeveloper(): The Game Developer's Source for OpenGL Coding
Main Menu
Latest News
Archived News
Tutorials
Links
E-Mail Me

Other
Message Board
My Guestbook

Intro to Constants
 


Quick Intro to Constants Page 1 of 2
< Previous Jump to Page: 1 | 2 Next >

Quick Intro to Constants

Say 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.

Quick Intro to Constants Page 1 of 2
< Previous Jump to Page: 1 | 2 Next >

This site best viewed with MS Internet Explorer 5.0 at 16-bit color and at least 800x600.

All Contents of this site are Copyright 1999, 2000 Joe Zimmerman. No part of this site (code, HTML, etc.) may be reproduced without my permission.

Click Here!