C++ Member Function Pointer Tutorial

preview_player
Показать описание
Tutorial on programming using member function pointers in C++.
Рекомендации по теме
Комментарии
Автор

Great Video! The concept for member function pointer and how / when to use them has been explained well

rajatgupta
Автор

Thank you so much, I have to learn this for my exam and couldn't find any clear video's of it.

zoe
Автор

Add(int, int) is faster than TwoArgFn(int, int). On an i7-3930K @ 4.5GHz using VS2012 on Win7 x64 with maximum optimization (tested by making as many calls as possibly to the function during a 5s interval):
Add(int, int) 1.1ns
TwoArgFunc(int, int) 2.8ns
The difference is real but insignificant for most use cases. Don't use function objects inside a large matrix multiplication...
For comparison:
Member Function call: 1.1ns
Virtual Function call: 4.0ns

My next post is on performance measurement.

jeffbenshetler
Автор

Question who will be faster Add(int, int) or

omahdezavalos
Автор

I´m missing one sample where a function pointer will be called in his own class. not in a new class.
I need for this a solution
Class x {

public
?(typedef ????) functionlist[] = {f1, f2, f3};
void f1 (void);
void f2 (void);
void f3 (void);
void loop();
}


void x::loop {
for (uint8_t i ; i < 3;i++{
//calling function
functionlist[i]();
}




}

AB-zhlp