My destructor doesnt work

I am trying to set an static member in a class to count how many object that class has, but as well I want to set a destructor in case I delete any object...the expamle is copied from here...http://www.cplusplus.com/doc/tutorial/templates/ on the static member section, but when I set my destructor It doesnt work...my program with the destrcutor is the next one...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 // static members in classes
#include <iostream>
using namespace std;

class Dummy {
  public:
    static int n;
    Dummy () { n++; };
	~Dummy() { n--; };

int Dummy::n=0;

int main () {
  Dummy a;
  Dummy b[5];
  cout << a.n << '\n';
  Dummy * c = new Dummy;
  cout << Dummy::n << '\n';
  delete c;
  cout<< Dummy::n <<"\n";
  return 0;
}
Beware of braces..

You haven't closed your class ..
Last edited on
upss, Sorry for bothering with stuff of a distracted guy.

Thanks a lot!!!
Topic archived. No new replies allowed.