The problem is as follows. I created a program, or rather a list, which displays the elements from the file by pressing the "a" key. Question: how to make, that after the deduced element by pressing on "a", by pressing on "d" to delete the last displayed elements in turn?
include <fstream> #include <iostream> #include <windows.h> #include <conio.h> using namespace std; struct el { string data; el *adres; }; class List { private: el * fadr, *eadr; public: List() { fadr = NULL; eadr = NULL; } void fadd(string a) { el *v; v = new el; v->data = a; v->adres = fadr; fadr = v; } void print() { if (fadr == NULL) { cout << "List is emptyn"; return; } el *v; for (v = fadr; v != NULL; v = v->adres) cout << v->data << " "; cout << endl; } }; int main() { ifstream input("c:\f.txt"); string s; while (!input.eof()) { char v = getch(); if (v != 'a') continue; getline(input, s); cout << s << endl; if (v != 'd') continue; // Вот тут что писать, чтобы он убрал последний выведенный элемент? } system("PAUSE"); return 0; }