fork download
  1. #include<iostream>
  2. #include<list>
  3.  
  4. using namespace std;
  5. //1ra clase base
  6. class Person
  7. {
  8. int e;
  9. public:
  10. Person(int);
  11. void printDates();
  12. };
  13.  
  14. Person::Person(int x)
  15. {
  16. e = x;
  17. }
  18. void Person::printDates()
  19. {
  20. cout << e;
  21. }
  22. int main()
  23. {
  24. list<Person> persons;
  25. for(int i = 0; i < 5; i++)
  26. {
  27. Person person(i);
  28. persons.push_front(person);
  29.  
  30. }
  31. // for(int i = 0; i < 5; i++)
  32. // {
  33. // hombres[i].printDates();
  34. // }
  35.  
  36. for(auto& person : persons) {
  37. person.printDates();
  38. }
  39.  
  40. }
Success #stdin #stdout 0s 4464KB
stdin
Standard input is empty
stdout
43210