基类与派生类的调用

定义时看的是等号右边的,析构时看的是等号左边的(析构函数不是虚函数时)

#include 
using namespace std;
#define MAXX 10005
#define MODD 1000000007
#define LL long long
#define mem(a, b) memset(a, b, sizeof(a));

class A
{
public:
    A()  {   cout << "A" << endl;  }
    ~A() {    cout<<"~A"<

基类与派生类的调用_第1张图片

#include 
using namespace std;
#define MAXX 10005
#define MODD 1000000007
#define LL long long
#define mem(a, b) memset(a, b, sizeof(a));
static int ss = 0;



class A
{
public:
    static int s ;
    A()  { cout << "A" << endl;  }
    virtual ~A() {    cout<<"~A"<s << endl;
        delete pa;
        cout << "YES" << endl;
        delete pb;

        A *pca = new A();
        cout << "YES" << endl;
        B *pcb = new B();
        delete pca;
        cout << "YES" << endl;
        delete pcb;
        return 0;
}

你可能感兴趣的:(知识积累)