Mylinux said:
why are these lines marked with #
C and C++ have 2 stage processing.
The first stage is the "c/c++ preprocessor" and anything with a # is
munged by the pre-processor.
The pre-processor manages directives like.
#define
#else
#endif
#if
#ifdef
#include
#line
#pragma
The # must be the first (non whitespace ?) character on the line for the
pre-processor to recognize it.
So, "#define" is a macro define directive. *IMPORTANT* - it is a
textual substitutionm - be VERY carful.
Here is an example where it does not do what you expect
#define CONSTANT 1+2 // constant is 1 plus 2
OK
cout << 100 * CONSTANT; // this is 300 --- right ? WRONG
The macro substitution leads to
cout << 100 * 1+2
which as you know will print 102.
Macros are great for some things but I reccomend you use enums and const
values.
e.g.
enum { CONSTANT = 1+2 };
or
const int CONSTANT = 1+2;
eg
panel.h
#define LINE_LENGTH 16
I want to define line_length 20
I should take away "#".
Write this as:
const int LINE_LENGTH=20;
and nuke the #define.