Boost C++ Libraries

submited by
Style Pass
2021-06-22 23:00:07

...one of the most highly regarded and expertly designed C++ library projects in the world. — Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Quite simple, and it is usable, but not generic. For a library it has to be designed way further. The design above can only be used for 2D points, for the struct mypoint (and no other struct), in a Cartesian coordinate system. A generic library should be able to calculate the distance:

The distance function can be changed into a template function. This is trivial and allows calculating the distance between other point types than just mypoint . We add two template parameters, allowing input of two different point types.

Consider a C++ class where member variables are protected... Such a class does not allow to access x and y members directly. So, this paragraph is short and we just move on.

Leave a Comment