← Quiz: References and Functions: all 10 questions
Quiz: References and Functions · Question 10 of 10
Why is an inline function safer than a function-like macro such as define SQ(x) xx?
Why is an inline function safer than a function-like macro such as #define SQ(x) x*x?
- A.inline functions are always faster
- B.Arguments are type-checked and evaluated once, as in a normal function call
- C.Macros cannot take arguments
- D.inline functions are stored in a separate file
Answer & explanation
Correct answer: Arguments are type-checked and evaluated once, as in a normal function call
SQ(a+1) expands to a+1*a+1, and SQ(i++) increments twice; an inline function has neither problem.
Can you get the rest right without peeking?
Take the timed Quiz: References and Functions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →