Skip to Content
Hands-On Design Patterns with C++
book

Hands-On Design Patterns with C++

by Fedor G. Pikus
January 2019
Intermediate to advanced
512 pages
14h 5m
English
Packt Publishing
Content preview from Hands-On Design Patterns with C++

Aggregate parameters

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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Structural Design Patterns in Modern C++

Structural Design Patterns in Modern C++

Umar Lone

Publisher Resources

ISBN: 9781788832564Supplemental Content