how to put a counter in constructor??
if you want to count the number of created objects, you can use a static (class) variable
class CountingClass {
private:
static int count;
public:
CountingClass() {
++CountingClass::count;
}
};
how to put a counter in constructor??
if you want to count the number of created objects, you can use a static (class) variable
class CountingClass {
private:
static int count;
public:
CountingClass() {
++CountingClass::count;
}
};
精彩评论