C++ class that mandates const objects

后端 未结 5 2040
盖世英雄少女心
盖世英雄少女心 2021-01-16 05:23

First let me ask a general question:

  • It seems to me that C++ is a language whose point is to provide tons of capabilities, to give the programmer the greatest
5条回答
  •  耶瑟儿~
    2021-01-16 06:17

    Just create your instance of the class as const. This will ensure all the internals are const.

    E.g. const MY_TYPE obj;

提交回复
热议问题