Content deleted Content added
added "in other languages" section |
|||
Line 89:
Each time an object of class <code>X</code> is created, the constructor of <code>counter<X></code> is called, incrementing both the created and alive count. Each time an object of class <code>X</code> is destroyed, the alive count is decremented. In this example, none of the functionality in the template uses the template parameter, and it is only used as a way of creating different static counters for different classes. Remember that each instantiation of a template with a type argument is a class of itself, and thus the static counter attributes in the <code>counter</code> template are different offering separated counters for <code>X</code> and <code>Y</code> classes.
==In other languages==
The CRTP makes an appearance in the [[Java language|Java programming language]] standard library where the [[Enum]] class is defined as <code>Enum<T extends Enum<T>></code>.
==See also==
|