#include #include "listobj.h" class Int : public Obj { static char* name; public: int val; Int(int v) { val = v; } char* className() { return name; } }; char* Int::name = "Int"; int main() { Int dez=10; List l; char str[31]; int i; while( 1 ) { printf("> "); gets_s(str, sizeof(str)); if( sscanf_s(str, " %d", &i, sizeof(i))==1 ) { l.insert(new Int(i)); } else { char c; sscanf_s(str, "%c", &c, sizeof(c)); if( c == 'q' ) break; } } printf("----------\n"); ListIter li(&l); li.first(); while( !li.end() ) printf("%d ", ((Int*)(li.next()))->val); printf("\n"); li.last(); while( !li.end() ) printf("%d ", ((Int*)(li.prev()))->val); printf("\n"); getchar(); }