O'Reilly logo

Imperfect C++ Practical Solutions for Real-Life Programming by Matthew Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Statics

Static objects are distinguished from stack variables and heap variables in that their storage is fixed and allocated by the linker, and their lifetimes are (largely) independent from the execution flow of the process. Static objects fall into three categories.

  1. Function-local static variables are those that are defined within function scope.

  2. Global and namespace-global static variables—also known as nonlocal statics—are those that are defined in the global namespace or within a named or anonymous namespace.

  3. Static member variables are those that are shared between instances of the class within which they're defined.

This chapter looks at the problems inherent in the use of static objects and suggests some measures to ameliorate ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required