here is a bit of code from AV, don't think of this as c++, really it should be thought of as an AV built ins scripting DSL that happens to get compiled by the c++ compiler.
void somemethod() { class PhilosophersStone { public: PhilosophersStone(vector<uint32_t> buildings, Project&; proj) { buildings.push_back(proj.Id()); proj.OnUpdateTurn = OnUpdateTurn; } static void OnUpdateTurn(Council& council, Player& player, Territory& territory, ControlModel& controlModel) { controlModel._commandAndControl += 5; } } philosophersStone(philosophy._buildings, PROJECT_TABLE.CreateProject(5000, 10000, "Philosophers Stone", "its super cool and stuff", list_of( PREREQUISITE_TABLE.TechRequisite(philosophy)))); }
as you look at this you may notice that ive managed to get way to much code into a class declaration, yes infact the last ';' you see there is the ';' you normally see on class rawr {}; <---- that one. You might be saying to your self "holy shit wtf is he doing", well one of the features inherited from C is that you can create an instance of a struct/class directly after the definition of the type. well since this is c++, i can add a constructor and put that sucker on the end. Next up I create a project with mostly simple parameters but wait!!!! wtf is this list_of thing? list_of comes from boost.Assignment and it allows me to define a collection inline. the somewhat odd syntax for multiple elements would be list_of(5)(4)(3)(2)(1), just a bit of an eye-full there with all the overloaded operator() action. Still this once again demonstrates to me how vastly superior C++ is to every other language on the planet(that includes spoken languages).
Trackbacks
Use the following link to trackback from your own site:
http://www.archverse.com/typo/trackbacks?article_id=5