| 1001010.com |
one zero zero one zero one zero dot com |
Note to self: the format of static template class member is
template<class T> int Test<T>::s_counter = 0;
And don't I forget it!
(what I originally forgot was the <T> - D'oH!)
// testtemplate.cpp : Defines the entry point for the console application.
#include "stdafx.h"
template <class T>
class Test
{
public:
static int s_counter;
Test()
{
s_counter++;
}
~Test()
{
s_counter--;
}
static int getInstanceCount()
{
return s_counter;
}
};
template<class T> int Test<T>::s_counter = 0;
int main(int argc, char* argv[])
{
Test<long> a,b,c,d,e,f,g[3];
printf("InstanceCount: %d\n", Test<long>::getInstanceCount());
return 0;
}