Where should you put global constants in a C++ program?

后端 未结 6 1271
日久生厌
日久生厌 2020-12-15 07:35

Where would you put global constants in a C++ application? For example would you put them in a class? In a struct?

6条回答
  •  不知归路
    2020-12-15 07:58

    One option is putting them into a class as non-static members and putting an object of that type inside your main() function. That simplifies making them non-globals when you find out that you need to, for whatever the reason.

提交回复
热议问题