Im confused at Symbolic Constants, I understand that they are a vlaue that cannot be changed and they are represented by a name.
I just dont understand. ANYONE?
ACAC
Im confused at Symbolic Constants, I understand that they are a vlaue that cannot be changed and they are represented by a name.
I just dont understand. ANYONE?
ACAC
http://www.t-p-n.co.uk//
check it out
Symbolic constants are used to make code clearer. Also, they make it easier to change the code. Example:
#define STATE_TAX 8.05
now, in your code, whenever the compiler sees the word STATE_TAX, it will replace STATE_TAX with 8.05
you write: total = cost * STATE_TAX
the compiler sees: total = cost * 8.05
so as you can see, symbolic constants make the code clearer, because if you scan the line you can immediately understand it, whereas if you just saw 8.05, you'd say 'what the heck is 8.05?'
Now, suppose the state tax decreases (fat chance, but let's suppose). If you hard-code 8.05, you will have to search out and replace every instance of 8.05 with, say, 7.95. But, if you have used the symbolic constant, all you must do is:
#define STATE_TAX 7.95 (and recompile)