January 2019
Intermediate to advanced
512 pages
14h 5m
English
With aggregate parameters, we create a struct or a class that contains all the values, instead of adding one parameter per value. We don't have to be limited to one aggregate; for example, our city may take several structs, one for all terrain-related features that the game sets, and another for all features that the player controls directly:
struct city_features_t { size_t number_of_buildings; size_t number_of_towers; size_t guard_strength; enum center_t { KEEP, PALACE, CITADEL }; center_t center = KEEP; bool with_forge = false; bool with_granary = false; bool with_temple;};struct terrain_features_t { bool has_fresh_water; bool is_coastal; bool has_forest; bool is_desert;}; class City { public: City(city_features_t city_features, ...