I have a C++ library I am going to distribute upon completion. Some of the header files for various classes have private variables which reference other code and require the developer to then include another header file in their code, or a cascade of header files if the referenced header is dependent on a host of others.
A good example of this would be a log file which uses an SqLite database as its storage mechanism. The class opens the database once and it remains open until the class destructor is called. Because the SqLite database object needs to remain open across calls to the methods of the class it is kept as a private class variable which requires #include <sqlite3.h> in the header file.
Is there a best practice or standard way of handling these sorts of situations? I want to avoid items like forward declarations in the header file.
I have thought about simply declaring such variables in the cpp body file, but it would not be encapsulated within the class in this approach, and I am not sure if there would be unintended consequences of this approach.
Another approach which does not seem elegant to me would be to create a second class to hold the private variables which then could be included in the cpp file without the need to put it in the header file. Any approach I come up with seems to be clunky and non-standard.
Your help would be greatly appreciated.