Use of 'const' for function parameters

前端 未结 30 3269
借酒劲吻你
借酒劲吻你 2020-11-22 03:06

How far do you go with const? Do you just make functions const when necessary or do you go the whole hog and use it everywhere? For example, imag

30条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 03:34

    I use const were I can. Const for parameters means that they should not change their value. This is especially valuable when passing by reference. const for function declares that the function should not change the classes members.

提交回复
热议问题