Why do we define InitGame() inside our .cpp file instead of our header file?

I had this doubt because, defining InitGame() inside BullCowCartridge.h and only calling it in our cpp file seemed to have worked just fine. So, is there anything I am missing?

Just to be sure I know what you mean. Could you give a code sample?

Because that would mean any file that needs to include “BullCowCartridge.h” will also be getting the definition and compiling it. With it separated only the .cpp needs to compile the definition.

Far more detailed answer here:

Be sure to read the linked answer (most upvoted) and not the one marked as the answer.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms