#include <iostream>
class A {
public:
int k;
void SetCount() {
static int n = 0;
k = n++;
};
};
int main() {
A *pA = new A();
pA->SetCount();
std::cout<<pA->k;
delete pA;
pA = new A();
pA->SetCount();
std::cout<<pA->k;
A a;
a.SetCount();
std::cout<<a.k;
delete pA;
return 0;
}
Login in to like
Login in to comment