This is the final post in a series on static variables, and in it I’ll talk about the final place we can put them – in template classes or functions.

If you’ve been following along, and you have a good understanding of how template classes work, you can almost certainly deduce how static variables will perform in this situation.

Essentially, because a template class is exactly that – a template – any static variables declared within it are only created if the template class is actually used to create a type.

Let’s quickly run through the basics of what a template class is, then the way that static variables behave will become clearer.