The inline facility is a C++ addition. C uses the preprocessor
#define statement to prove macros, a crude implementation of
inline code. For instance, here's a macro for squaring a number:
#define SQUARE(X) X*X
This works not by passing arguments but by text substitution, with the
X
acting as a symbolic label for the "argument".
a = SQUARE(5.0); is repalced by a = 5.0*5.0;
b = SQUARE(4.5 + 7.5); is replaced by b = 4.5 + 7.5 * 4.5 + &.5;
d = SQUARE(C++); is replaced by d = c++ * c++;
Only the first example works properly. You can improve matters with a
liberal application of parentheses:
#define SQUARE(X) ((X)*(X))
Still, the problem remains that macros don't pass by value.
Even with this new definition, SQUARE(C++) increments C
twice.