#include
using namespace std;
class Base
{
friend void fun();
public:
Base(int data = 0)
:b(data)
{
cout << "Base()" << endl;
}
~Base()
{
cout << "~Base()" << endl;
}
static void show()
{
cout << "static show()" << endl;
}
void add()
{
a++;
}
static int a;
private:
int b;
};
int Base::a = 0;
class Derive :public Base
{
public:
Derive(int data = 0)
:d(data)
{
cout << "Derive()" << endl;
}
~Derive()
{
cout << "~Derive()" << endl;
}
void Add()
{
a++;
}
private:
int d;
};
int main()
{
Derive d;
d.show();
d.a = 2;
d.add();
d.Add();
cout << d.a << endl;
return 0;
}
Base()
Derive()
static show()
4
~Derive()
~Base()