AMDG Ramon F Herrera wrote:
This is my first non-trivial, multi-file C++ program with classes and I bumped into a problem. See example from the Regex library below.
The problem occurred after I converted the simple code below to a class (called "Pairs"). The troublesome statement is this one, where we attempt to take the address of a function.
std::for_each(m1, m2, ®ex_callback);
My first compilation attempt produces an error message from the compiler, which is nice enough to offer a solution:
pairs.cpp:247: error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member func tion to form a pointer to member function. Say `&Pairs::assignment_callback'
So, following the compiler's suggestion, I changed the line above to this:
std::for_each(m1, m2, &Pairs::assignment_callback);
Now, I am getting an inscrutable (for me, anyway) error message:
stl_algo.h:158: error: must use .* or ->* to call pointer-to-member function in `__f (...)'
Thanks for your kind assistance,
Try
#include