Welcome to the Treehouse Community
Looking to learn something new?
Global constants question
Couldn't we have declared them all in the header file only along with their values? Instead of having declared them in the implementation and then making them accessible in the header file?
Rashii Henry16,433 Points
Declaring those classes within the header file is a common practice and fine. The header file (also known as the interface) is where you want to declare your variables. Simply because inside of your header file you're basically saying, 'Im giving you all the tools to work with'.
Then your implementation takes these tools (the ones that you gave it to work with), so it can implement, or work with those tools the way you intend for them to work.
To answer your question, we could have only declared them in the header file and made them accessible globally. However, the same variables that were declared and initialized within the implementation, needed to be used privately within that same class. So, in those dictionaries we wanted to pass in STATIC VARIABLES into the dictionary and NOT string literals.