Virtual Methods or Function Pointers

Approach 1 (Virtual Function) “+” The “correct way to do it in C++ “-” A new class must be created per callback “-” Performance-wise an additional dereference through VF-Table compared to Function Pointer. Two indirect references compared to Functor solution. Approach 2 (Class with Function Pointer) “+” Can wrap a C-style function for C++ Callback … Read more

Function pointer vs Function reference

Functions and function references (i.e. id-expressions of those types) decay into function pointers almost immediately, so the expressions func and f_ref actually become function pointers in your case. You can also call (***func)(5) and (******f_ref)(6) if you like. It may be preferable to use function references in cases where you want the &-operator to work … Read more

What is meaning of a pointer to a constant function?

In C, there’s no such thing as a function being const or otherwise, so a pointer to a const function is meaningless (shouldn’t compile, though I haven’t checked with any particular compiler). Note that although it’s different, you can have a const pointer to a function, a pointer to function returning const, etc. Essentially everything … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)