I am attempting to modify and improve a job scheduler application in C++
Many of the member functions are declared as static
, and hence cannot act on the non-static member variables.
The problem arises when attempting to add additional functionality to the class. In particular, I was wondering if it was possible to call a non-static member function inside the definition of a static member function.
That is, suppose we have the member functions declarations:
static void email(CString message);
CRecordset * Select(CString SQL, CDatabase* dataBase);
I would like to call the Select
function from within the implementation of the email
function. But I get an error:
error C2352: 'CSchedulerDlg::Select' : illegal call of non-static member function
The error makes sense because static member functions cannot act upon the current object, but I still need to perform the Select
function from within the email
function. Does there exist a work around method?
The relevant code that causes the error is:
void CSchedulerDlg::email(CString message)
{
CRecordset * emails = Select("some SQL query", db);
}
where static CDatabase* db
is a private member variable within the class.