Okay, so this should be the final question before finishing the Windows version of OP2Archive...
I'm on the final cycles of refactoring the code. I keep on catching missing include files that do not force the program to fail when compiling.
What I mean is the header file below depends on the standard library string class. ConsoleSettings.h also depends on string. So, if I do not include string in ConsoleList.h, the program will compile and run fine without any warnings.
However, if some day in the future ConsoleSettings.h eliminates its dependency on string, then ConsoleList longer compile. This would be an odd and unintended consequence of removing a dependency from ConsoleSettings.h. So to prevent something like this, I'm being careful to try and include string in ConsoleList.h and other files that use it even when they don't currently require it to compile.
It seems like I'm always finding one that I'm missing while refactoring. Is there some way to simplify this problem by having the compiler/IDE complain about missing includes in a file that are contained in another file? Or, am I just overthinking this and shouldn't worry so much about finding and listing all the includes since they are covered in another dependency?
This affects declaring namespaces in the same way.
At first when learning C++, dealing with this weird behavior of includes and using namespace statements caused me a lot of confusion. I've learned to recognize when they are causing problems now, but what a headache!
ConsoleList.h#pragma once
#include "ArchiveConsoleListing.h"
#include "ConsoleSettings.h"
#include <string>
using namespace std;
class ConsoleList
{
public:
void listCommand(const ConsoleArgs& consoleArgs);
private:
ArchiveConsoleListing archiveConsoleListing;
void listArchiveContents(const string& filename);
void listAllArchivesInDirectory(const string& directory);
};
Thanks,
Brett