Why is const-correctness specific to C++?

后端 未结 14 598
盖世英雄少女心
盖世英雄少女心 2020-12-23 16:42

Disclaimer: I am aware that there are two questions about the usefulness of const-correctness, however, none discussed how const-correctness is necessary in C++ as oppos

14条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 17:02

    I don't think anybody claims const-correctness is "necessary". But again, classes are not really necessary either, are they? The same goes for namespaces, exceptions,... you get the picture.

    Const-correctness helps catch errors at compile time, and that's why it is useful.

提交回复
热议问题