Immutable container with mutable content

后端 未结 4 1768
遇见更好的自我
遇见更好的自我 2021-01-04 15:49

The story begins with something I thought pretty simple :

I need to design a class that will use some STL containers. I need to give users of the class access to an

4条回答
  •  不知归路
    2021-01-04 16:05

    The simplest option would probably be a standard STL container of pointers, since const-ness is not propagated to the actual objects. One problem with this is that STL does not clean up any heap memory that you allocated. For that take a look at Boost Pointer Container Library or smart pointers.

提交回复
热议问题