fork download
  1. #include <list>
  2.  
  3. struct Grass {
  4. struct {
  5. int x, y;
  6. } position;
  7. };
  8.  
  9. int main() {
  10. std::list<Grass*> grassList;
  11. for(int i=0;i<50;i++){
  12. for(int j=0;j<50;j++){
  13. auto g1 = new Grass;
  14. g1->position.x = i;
  15. g1->position.y = j;
  16. grassList.push_back(g1);
  17. }
  18. }
  19. // ...
  20. for (auto& g1: grassList) {
  21. delete g1;
  22. }
  23. grassList.clear();
  24. }
  25.  
Success #stdin #stdout 0s 3408KB
stdin
Standard input is empty
stdout
Standard output is empty