Can I use const in vectors to allow adding elements, but not modifications to the already added?

后端 未结 14 630
既然无缘
既然无缘 2020-12-01 04:54

My comments on this answer got me thinking about the issues of constness and sorting. I played around a bit and reduced my issues to the fact that this code:



        
14条回答
  •  孤独总比滥情好
    2020-12-01 05:29

    You're going to need to write your own class. You could certainly use std::vector as your internal implementation. Then just implement the const interface and those few non-const functions you need.

提交回复
热议问题