Answers/Solutions to Exercises in Chapter 8, Exercise 7

E7: Write a C++ program in which an object is created that has some static data, some data on the stack, and some data on the heap. Do not peek at the next exercise. Designing programs like this is not advisable for the real life!

A7: See the program in E8. When inside the function doit(), a is defined in the static part of the program, however a.heap_string points to a string on the heap, while a.stack_string points to a string on the stack.

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