#include #include using namespace std; template class base { static int n; public: base() {++n;} base(const base& another) {++n;} ~base() {--n;} static int count() {return n;} }; template int base::n = 0; class derived1: public base { //etc. }; class derived2: public base { //etc. }; int main() { derived1 a, b, c; derived2 d; cout << "derived1::count " << derived1::count() << "\n" << "derived2::count " << derived2::count() << "\n"; return EXIT_SUCCESS; }