I have code similar to the following:
template<class BASE_TYPE = COdbcQuery>
class CRemoteQuery : public BASE_TYPE
{
CRemoteDatabase m_Db;
public:
CRemoteQuery()
: BASE_TYPE(&m_Db)
{
}
~CRemoteQuery()
{
}
};
My problem is that m_Db.Open()
must be called before passing m_Db
to the base constructor.
If I call a method as an argument to the base constructor that calls Open()
, it fails because m_Db
has not yet been initialized.
I tried creating a virtual method in the base class, which would be called during initialization and this class could override, but template classes cannot override virtual methods.
Restructuring my base classes so that m_Db
doesn't need to be opened first raises a lot of difficult issues. Is there no way to do this?