cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
symbolic constant
symbolic constant
Sep 17, 2014 at 8:49am UTC
xenovia12
(658)
i dont see any better use of #define i mean why should i use it when i can just declare a variable using constant
constant km_per_miles=1.609;
instead of
#define km_per_miles 1.609
i just using it as header guards
1
2
ifdef ifndef
Sep 17, 2014 at 9:00am UTC
Peter87
(11234)
I agree. Using
const
is much better. I think using
#define
to define constants is an old habit from C from before the
const
keyword existed.
Last edited on
Sep 17, 2014 at 9:11am UTC
Sep 17, 2014 at 9:10am UTC
keskiverto
(10402)
The #define is an instruction for preprocessor; the compiler never sees it. It has uses (like the include guards), but should not be used for what the language (C++) has intrinsic support for.
Sep 17, 2014 at 9:12am UTC
xenovia12
(658)
k ty
#define C "sucks"
Topic archived. No new replies allowed.