#include <iostream>
using namespace std;
class Cat {
public:
Cat(int age):
itsAge(age){
numofcats++;
}
virtual~Cat() {
numofcats--;
}
virtual int getage() {
return itsAge;
}
virtual void setage(int age) {
itsAge = age;
}
static int getnumofcats() {
return numofcats;
}
private:
int itsAge;
static int numofcats;
};
int Cat::numofcats = 0;
void telepathicfunction();
int main(){
const int maxcats = 5;
Cat* Cathouse[maxcats];
int i;
for (i = 0; i < maxcats; i++) {
Cathouse[i] = new Cat(i);
telepathicfunction();
}
for (i = 0; i < maxcats; i++) {
delete Cathouse[i];
telepathicfunction();
}
return 0;
}
void telepathicfunction() {
cout << "There are" << Cat::getnumofcats() << "Cats alive!\n";