#include <iostream>
template<class T>struct Counter {
Counter() { ++count; }
static int count;
};
template<class T> int Counter<T>::count = 0;
struct Derived1: Counter<Derived1> {};
struct Derived2: Counter<Derived2> {};
int main(int argc, char** argv)
{
Derived1 a, b;
Derived2 c;
std::cout << Derived1::count << Derived2::count << '\n';
return 0;
}
Login in to like
Login in to comment