![]() |
[c++] symbolic constants
I'm having trouble figuring out how to represent the value of pi in two different ways using symbolic constants. The book is giving me no useful info. Could I get some help? Thanks.
|
Symbolic constants are just defines.
So #define PI 3.14 is one way to represent PI |
hey thanks. Could I also do something like: Const PI = 3.14 as the second way. Or can I just do #define PI 3.1415?
|
#define PI 3.1415 is the same method as #define PI 3.14 and Const PI = 3.14 wouldn't be a symbolic constant. Think about what #define does. It replaces the token PI in the source code with the number 3.14 before the code is compiled. Using this idea, a #define could be more than a number...
|
Keep in mind though that if you are using the term const, you need a type, it would be
const double PI = 3.14 |
All times are GMT -8. The time now is 02:42 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project