#include #include #include "grandchild.h" using namespace std; int main() { base b(10); middle m(10, 20); grandchild g(10, 20, 30); const base *const a[] = {&b, &m, &g, 0}; const size_t n = sizeof a / sizeof a[0]; for (size_t i = 0; i < n; ++i) { cout << "a[" << i << "]: "; if (a[i] == 0) { cout << "zero pointer"; } else { cout << *a[i] << " "; } const middle *const p = dynamic_cast(a[i]); if (p) { p->newfunc(); } cout << "\n"; } return EXIT_SUCCESS; }