#include <iostream> #include <list> #include <algorithm> #include "vehicle.h" #include "car.h" #include "bus.h" #include "truck.h" using namespace std; void global_print(vehicle *vp) { vp->print(); } int main() { list<vehicle*> vl; vl.push_back( new car("abc123") ); vl.push_back( new bus("bbb123", 45) ); vl.push_back( new truck("eee765", 4.5) ); vl.push_back( new truck("fff098", 3.5) ); vl.push_back( new bus("ccc456", 55) ); vl.push_back( new car("bcd2") ); /* for ( list<vehicle*>::iterator vi = vl.begin(); vi != vl.end(); ++vi) { global_print(*vi); } */ for_each( vl.begin(), vl.end(), global_print); return 0; }