Inheriting classes from std::

后端 未结 4 1578
甜味超标
甜味超标 2020-12-22 05:41

There are many similar questions and I found both pro and against reasons to use this pattern so I am asking this here:

I need to make a JSON implementation in C++ (

4条回答
  •  借酒劲吻你
    2020-12-22 06:11

    I think it is actually better to wrap it within your own class (i.e. proxy using std as member) since it makes it much more loosely coupled and if you would like to use a different data structure it would be quite easy, since you could simply modify your own class while the std classes should not be modified at all. If the interface of your objects is simple, maybe you should even implement your own interface (to make it easily compatible when you want to use a different data structure from std or boost or whatever suits your needs). Your current implementation is maybe not the best one at mentioned in the comments, but i would still recommend wrapping std uses in your own class (especially in larger applications).

提交回复
热议问题