Answers/Solutions to Exercises in Chapter 5, Exercise 4

E4: Explain why the variables of a function f()cannot retain values between two consecutive activations of f().

A4: Well, it is not a sufficiently precise question, if you not doubt noticed. A static variable of the function f() is located in the static data section of the program's address space, and hence exists throughout the duration of the program's execution, and as such it can retain its value between two consecutive activations. On the other hand, an auto variable of f() is located in the activation frame of f(), and such it comes to existence on the activation of f() and is destroyed on the termination of f() --- that's why it cannot retain values between two consecutive activations of f().

Back to Answers/Solutions Index                          Back to Answers/Solutions for Chapter 5 Index