Alx09

Untitled

Nov 23rd, 2020
405
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <list>
  3. #include <iterator>
  4. #include <stdlib.h>
  5. using namespace std;
  6.  
  7. class Test {
  8. private: int id;
  9. public:
  10.     Test(int id) {
  11.         this->id = id;//builder
  12.     }
  13.  
  14.     void Show() {
  15.         cout << id << '\n';
  16.     }
  17. };
  18.  
  19. void ShowLista(list <Test> test) {
  20.     for (list <Test> ::iterator it = test.begin(); it != test.end(); it++)it->Show();
  21.  
  22. }
  23.  
  24.  
  25. int main() {
  26.     list <Test> test; // lista
  27.     test.push_front(2); // aduagam in fata
  28.     test.push_back(1); // aduagam in spate se apeleaza constroctorul
  29.     test.push_front(100);// adaugam in fata
  30.     ShowLista(test);// afisam
  31.  
  32.     system("pause");
  33. }
RAW Paste Data