tom dunigan
/
antsnbugs
stochastic simulation, predator/prey
Counter.h@0:fc1335b7b54f, 2019-12-23 (annotated)
- Committer:
- manitou
- Date:
- Mon Dec 23 18:56:56 2019 +0000
- Revision:
- 0:fc1335b7b54f
stochastic simulation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
manitou | 0:fc1335b7b54f | 1 | #ifndef MYCOUNTER |
manitou | 0:fc1335b7b54f | 2 | #define MYCOUNTER |
manitou | 0:fc1335b7b54f | 3 | template <typename T> |
manitou | 0:fc1335b7b54f | 4 | struct counter |
manitou | 0:fc1335b7b54f | 5 | { |
manitou | 0:fc1335b7b54f | 6 | counter() |
manitou | 0:fc1335b7b54f | 7 | { |
manitou | 0:fc1335b7b54f | 8 | objects_created++; |
manitou | 0:fc1335b7b54f | 9 | objects_alive++; |
manitou | 0:fc1335b7b54f | 10 | } |
manitou | 0:fc1335b7b54f | 11 | |
manitou | 0:fc1335b7b54f | 12 | virtual ~counter() |
manitou | 0:fc1335b7b54f | 13 | { |
manitou | 0:fc1335b7b54f | 14 | --objects_alive; |
manitou | 0:fc1335b7b54f | 15 | } |
manitou | 0:fc1335b7b54f | 16 | static int objects_created; |
manitou | 0:fc1335b7b54f | 17 | static int objects_alive; |
manitou | 0:fc1335b7b54f | 18 | }; |
manitou | 0:fc1335b7b54f | 19 | template <typename T> int counter<T>::objects_created( 0 ); |
manitou | 0:fc1335b7b54f | 20 | template <typename T> int counter<T>::objects_alive( 0 ); |
manitou | 0:fc1335b7b54f | 21 | #endif |