#include <iostream>
using namespace std;
class MyClass
{
public:
static int s_Total;
MyClass(int level = 0);
static int GetTotal();
private:
int myLevel;
};
int MyClass::s_Total = 0;
MyClass::MyClass(int level):myLevel(level)
{
cout << "born!" << endl;
++s_Total;
}
int MyClass::GetTotal()
{
return s_Total;
}
int main()
{
cout << MyClass::s_Total << "\n\n";
MyClass myObject1, myObject2, myObject3;
cout << MyClass::GetTotal() << "\n";
return 0;
}
|