20.08

20.08

#include <iostream>


using namespace std;


class x { virtual void f() = 0; };


class b

{

char * pc;

public:

b(char * b): pc(_strdup(b)) {}

virtual void sh()

{

cout << pc << endl;

}

~b() { cout << 'b'; delete[]pc; }

};


class d : public b

{

char * pc;

public:

d(char * pc, char * pc_b) : pc(_strdup(pc)), b(pc_b) {}

void sh()

{

cout << pc << endl;

}

~d() { cout << 'd'; delete[]pc; }

};


void main()

{

{size_t cnt, ci;

b * mb[5] = { new b("abc") , new d("+-*/[]","78567") };

cnt = 2;

for (ci = cnt; ci--;)

mb[ci]->sh();


for (ci = cnt; ci--;)

delete mb[ci];

}

system("pause");

}