#include #include #include "base.h" #include "derived.h" using namespace std; int main() { base b1(10, 20); base b2(30, 40); derived d1(50, 60, 70, 80); derived d2(90, 100, 110, 120); base *const a[] = { //base is the "greatest common denominator" &b1, &b2, &d1, &d2 }; const size_t n = sizeof a / sizeof a[0]; for (size_t i = 0; i < n; ++i) { a[i]->print(); cout << "\n"; } cout << "\n"; //The same loop, but with a pointer p instead of a size_t i. for (const base *const *p = a; p < a + n; ++p) { (*p)->print(); cout << "\n"; } return EXIT_SUCCESS; }