#include #include "Container.h" #include "EvenContainer.h" using namespace std; void PrintContainer(const Container & a); void ChangeContainer(Container & a); int main() { Container a({4,2,7,6,4}); Container b; EvenContainer w; EvenContainer x{1,2,3,4,5,6,7,8,9}; cout << "The contents of a, the base class" << endl; PrintContainer(a); cout << endl; ChangeContainer(a); cout << "After the call to ChangeContainer" << endl; PrintContainer(a); cout << endl; cout << "The container x holds " << endl; PrintContainer(x); //x[0] = 5; x.Insert(100); x.Insert(101); x.InsertNextEven(1000); x.InsertNextEven(2001); cout << "The container x holds " << endl; PrintContainer(x); ChangeContainer(x); cout << "The container x holds " << endl; PrintContainer(x); Container * tmp = new EvenContainer; cout << "The base pointer can get to the size " << tmp->Size() << endl; //tmp->InsertNextEven(99999); reinterpret_cast(tmp)->InsertNextEven(99999); cout << "After a cast, here is the new list " << endl; PrintContainer(*tmp); delete tmp; return 0; } void ChangeContainer(Container & a){ size_t i; for(i =0; i < a.Size(); i++) { a[i] = a[i]*4 +1; } return; } void PrintContainer(const Container & a){ size_t i; for(i =0; i < a.Size(); i++) { cout << a[i] << " "; } cout << endl; return; }