Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 292
FevDeses Avatar asked Mar 05 '10 13:03

FevDeses


1 Answers

I would use a namespace for global constants which are not very strongly associated with a single class. In the latter case, I would put them in that class.

Really global (application-level) constants should be in the application's namespace (provided your application is inside it's own namespace, as it should be). For module-level constants, the module's own namespace is the natural place.

like image 122
Péter Török Avatar answered Sep 21 '22 13:09

Péter Török