Question 5
Back to Exercise
Which statement about #define PI 3.14159 versus const double PI = 3.14159; is true?
- A Both are typed variables
- B The macro is untyped text replaced by the preprocessor and ignores scope; the const is a typed, scoped object Correct
- C The macro uses memory at run time
- D const is replaced by the preprocessor
Correct Answer: Option B
The preprocessor substitutes the macro's text before compilation, so it has no type, no address and no scope. The const has a type the compiler checks, obeys block scope and is visible in a debugger.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!