addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Chicago C/C++ Users Group Message Board › An unsolved OOP problem

An unsolved OOP problem

Marcin Z.
marcinzalewski
Bloomington, IN
Post #: 2
I have been chatting with Jeremiah Willcock (http://osl.iu.edu/~je...­) about associations in C++, and he came up with two prototype implementations on the fly:

http://www.osl.iu.edu...­
http://www.osl.iu.edu...­

Note that these are just examples, without proper library framework and error handling. But, the code illustrates how associations can be achieved. The "type_info" version works by "type erasure," storing roles in a map with role's type_info as a key. This could be done much better, in principle, using one of the boost libraries such as boost::any. The idea is, though, that each person has a map of its roles.

The second example stores roles "per role," i.e., it has one map per role. The map associates each object that has that role to the role value.

Further variations on that design are possible, including statically enforced and checked associations.
Powered by mvnForum

Our Sponsors

  • Here

    Many thanks to Here for sponsoring our event of September 21, 2017

  • EZE Software Group

    Many thanks to EZE Software Group for providing us with a place to meet.

  • Spot Trading, LLC

    Many thanks to Spot Trading, LLC, for providing us with a place to meet.

  • JetBrains

    Many thanks for giving us free coupons for their software products

  • Optiver

    Thanks for hosting and organizing events in October 2015 and July 2016.

  • 8th Light

    Many thanks to 8th Light for providing us with food and beverages.

  • New Horizons Computer Learning Centers

    .

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy