Advertisement
Alx09

Untitled

Nov 23rd, 2020
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement