Correct usage(s) of const_cast<>

后端 未结 8 823
陌清茗
陌清茗 2020-12-02 14:23

As a common rule, it is very often considered a bad practice to use const_cast<>() in C++ code as it reveals (most of the time) a flaw in the design.

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 14:47

    Yes of course, when your calling code that you can't modify and isn't const correct. It should be noted that you should only use it with calls to functions that you know for certain won't modify your data!

提交回复
热议问题