#ifndef
#define
#include <iostream>
using namespace std;
class A{
public:
A();
~A();
};
#endif
#include "A.h"
A::A() {
cout << "A::A()" << endl;
}

A::~A() {
cout << "A::~A()" << endl;
}
#ifndef
#define
#include "A.h"
using namespace std;
class B:public A{
public:
B();
~B();
};
#endif
#include "B.h"
B::B() {
cout << "B::B()" << endl;
}

B::~B() {
cout << "B::~B()" << endl;
}
#include "A.h"
#include "B.h"
#include <stdio.h>

void f() {
//基类指针指向动态(new)创建的派生类对象,会发生内存泄漏
A *p = new B;
if (p != NULL) {
delete p;
p = NULL;
}
}

int main() {

f();
return 0;
}