I'm using C++17 in Visual Studio 2017. I want to execute a class method in another class method, using lambda expressions. I have done it this way so far:
void CMFCApplicationDlg::Add_text() {
std::ofstream outfile;
outfile.open("test.txt", std::ios_base::app);
outfile << "text added" << std::endl;
}
void CMFCApplicationDlg::Start_adding() {
sched.cron("0 12 * * *", [this]() { CMFCApplicationDlg::Add_text(); });
}
I think it would be better if it's possible to send a pointer of Add_text
to Start_adding
as a parameter and use it with lambda expressions.
How can I:
- Make a pointer of a class method?
- Send it to another method?
- Run it in a lambda function?
I'd appreciate it if I could get some example code.