   initializing a static int
  Hi,I have a class (shown below) and I am trying to keep a count of how many times the destructor for this class has been called. This count should cover all instances of class A.I think I need to use a static int but I am having trouble initializing it, i am getting the error message:'count' : pure specifier can only be specified for functionsObviously I cannot initialize it within the constructor as I do not want it to keep being reset to 0. class A{    private:   static int count = 0; public:    A() { cout << "Constructor activated"; }    ~A() { count++;   cout << "Destructor activated"; }};Has anyone got any suggestions?Help would be much appreciated.Thanks Gooner   
  Declare it in the class and then init it as shown at global file scope in your cpp file (ie, not in a function or anything).class A{private:static int count; public:A() { cout << "Constructor activated"; }~A() { count++; cout << "Destructor activated"; }};int A::count = 0;;  You cannot declare things like that.  You need to set it outside the class like:class A{    private:   static int count; public:    A() { cout << "Constructor activated"; }    ~A() { count++;   cout << "Destructor activated"; }};int A::count = 0;;  Thanks alot, much appreciated.   ;  Just as a side note, it's perfectly legal to declare static consts in classes like that.Ie:class Foo{   ...   static const int MyConst = 10;   ...};