I am working on a program for my CS class. It is a simulation of a delivery company's activities at an airport.
This is a very simple, small program consisting of a few header and source files and a main.cpp source file that orchestrates the simulation.
There are certain given constant values, such as the frequency of shipment arrival, the load capacity of planes, the amount of time it takes a worker to process certain items, etc. (all are integer values). It is necessary for me to access these variables throughout several functions in main.cpp
It seemed reasonable to declare these above the main() function as const ints, effectively making them global, e.g.
const int kTotalTime = 2000;
const int kPlaneCapacity = 25;
int main(){//...program code}
I am aware that global variables are to be avoided in most situations, as there are no restrictions on where they can be called and/or modified, which can lead to accidentally breaking parts of the program which in turn may be difficult to debug, as well as causing compatibility issues for future code, etc. However since these are read-only values of a primitive data type, which are used throughout the program, it seemed like a reasonable solution. Also, it makes an explicit statement about the purpose of the variables to anyone reading the code as well as to the compiler.
Questions: Is my logic flawed? How so? When are global variables (const or not) reasonable to use? If this is a bad solution, then how would you suggest declaring constant read-only values such as these?
Thank you very much for your time!