C++ const modifier with primitive types

后端 未结 5 2052
死守一世寂寞
死守一世寂寞 2020-12-31 12:16

Should I pay attention on const modifier working with primitive types? Which one is more syntactically correct and why?

First version:

f         


        
5条回答
  •  鱼传尺愫
    2020-12-31 13:03

    There's no difference at all between the 2nd and the 3rd versions. Choose one which is the shortest to type :)

    There's a little difference between the 1st and the 3rd. You might prefer the 3rd if you are afraid of accidentally modifying a and b inside the function.

提交回复
热议问题