Skip to content

Instantly share code, notes, and snippets.

@yasuakiohama
Created November 22, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasuakiohama/d78f40415599e0670ba0 to your computer and use it in GitHub Desktop.
Save yasuakiohama/d78f40415599e0670ba0 to your computer and use it in GitHub Desktop.
FunctionPointer.cpp
#include <stdio.h>
#include <iostream>
#include "FunctionPointer.hpp"
void FunctionPointer::run1() {
void (FunctionPointer::*pFunc)() = &FunctionPointer::func1;
(this->*pFunc)();
pFunc = &FunctionPointer::func2;
(this->*pFunc)();
}
void FunctionPointer::run2() {
m_pFunc = &FunctionPointer::func1;
(this->*m_pFunc)();
m_pFunc = &FunctionPointer::func2;
(this->*m_pFunc)();
SetFunc(&FunctionPointer::func3);
(this->*m_pFunc)();
}
void FunctionPointer::SetFunc(void (FunctionPointer::*pFunc)())
{
m_pFunc = pFunc;
}
void FunctionPointer::func1() {
printf(" void FunctionPointer::func1()\n");
}
void FunctionPointer::func2() {
printf(" void FunctionPointer::func2()\n");
}
void FunctionPointer::func3() {
printf(" void FunctionPointer::func3()\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment