1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | class EntityCollection { public: typedef std::list<Entity*> EntityList; typedef EntityList::iterator iterator; EntityCollection(EventType event){ EventSystem::listenToEvent(event, this); } ~EntityCollection(){ clear(); } void onEvent(Entity* entity){ mQueue.push_back(entity); } bool emtpy() const{ return mQueue.empty(); } iterator begin(){ return mQueue.begin(); } iterator end(){ return mQueue.end(); } void clear(){ // Delete entities. } private: EntityList mEntities; }; |
Y2xhc3MgRW50aXR5Q29sbGVjdGlvbgp7CnB1YmxpYzoKICAgIHR5cGVkZWYgc3RkOjpsaXN0PEVudGl0eSo+IEVudGl0eUxpc3Q7CiAgICB0eXBlZGVmIEVudGl0eUxpc3Q6Oml0ZXJhdG9yIGl0ZXJhdG9yOwoKICAgIEVudGl0eUNvbGxlY3Rpb24oRXZlbnRUeXBlIGV2ZW50KXsKICAgICAgICBFdmVudFN5c3RlbTo6bGlzdGVuVG9FdmVudChldmVudCwgdGhpcyk7CiAgICB9CgogICAgfkVudGl0eUNvbGxlY3Rpb24oKXsKICAgICAgICBjbGVhcigpOwogICAgfQoKICAgIHZvaWQgb25FdmVudChFbnRpdHkqIGVudGl0eSl7CiAgICAgICAgbVF1ZXVlLnB1c2hfYmFjayhlbnRpdHkpOwogICAgfQoKICAgIGJvb2wgZW10cHkoKSBjb25zdHsKICAgICAgICByZXR1cm4gbVF1ZXVlLmVtcHR5KCk7CiAgICB9CgogICAgaXRlcmF0b3IgYmVnaW4oKXsKICAgICAgICByZXR1cm4gbVF1ZXVlLmJlZ2luKCk7CiAgICB9CgogICAgaXRlcmF0b3IgZW5kKCl7CiAgICAgICAgcmV0dXJuIG1RdWV1ZS5lbmQoKTsKICAgIH0KCiAgICB2b2lkIGNsZWFyKCl7CiAgICAgICAgLy8gRGVsZXRlIGVudGl0aWVzLgogICAgfQoKcHJpdmF0ZToKICAgIEVudGl0eUxpc3QgbUVudGl0aWVzOwp9Ow==
prog.cpp:4: error: ISO C++ forbids declaration of ‘list’ with no type prog.cpp:4: error: typedef name may not be a nested-name-specifier prog.cpp:4: error: expected ‘;’ before ‘<’ token prog.cpp:5: error: ‘EntityList’ has not been declared prog.cpp:5: error: ISO C++ forbids declaration of ‘iterator’ with no type prog.cpp:5: error: typedef name may not be a nested-name-specifier prog.cpp:5: error: expected ‘;’ before ‘iterator’ prog.cpp:7: error: expected `)' before ‘event’ prog.cpp:15: error: ‘Entity’ has not been declared prog.cpp:23: error: ‘iterator’ does not name a type prog.cpp:27: error: ‘iterator’ does not name a type prog.cpp:36: error: ‘EntityList’ does not name a type prog.cpp: In member function ‘void EntityCollection::onEvent(int*)’: prog.cpp:16: error: ‘mQueue’ was not declared in this scope prog.cpp: In member function ‘bool EntityCollection::emtpy() const’: prog.cpp:20: error: ‘mQueue’ was not declared in this scope
-
result: Compilation error (maybe you wish to see an example for C++ 4.7.2)


