#include #include class List { List* _before; static List* _after; char _data; public: List(char c) { _before = this; if (_after == 0) _after = this; _data = c; } List* insert(List* x) { x->_before = this; x->_after = _after; _after->_before = x; _after = x; return x; } void print() { List *tmp = _after->_before; while (tmp != this) { putchar(tmp->_data); tmp = tmp->_before; } putchar(tmp->_data); putchar('\n'); } }; List *List::_after = 0; void main() { char *s = strdup("9214757"); List* aNode = new List('9'); for (int i = 0; i < 7; i++) { aNode = aNode->insert(new List(s[i])); } aNode->print(); }