static string constants in class vs namespace for constants [c++]

前端 未结 4 471
情歌与酒
情歌与酒 2020-12-14 02:17

I want to declare string constants that will be used across various classes in the project. I am considering two alternatives

Option 1:

<         


        
4条回答
  •  清歌不尽
    2020-12-14 02:52

    Option 1 achieves the same as Option 2, but in a messier way.

    If you're going to use a class that just has static members, especially for global access/constants, use a namespace.

提交回复
热议问题