Skip to content

Instantly share code, notes, and snippets.

@yasuakiohama
Created November 22, 2015 14:10
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/da6b8cbf42ae5a7760ad to your computer and use it in GitHub Desktop.
Save yasuakiohama/da6b8cbf42ae5a7760ad to your computer and use it in GitHub Desktop.
FunctionPointerMain.cpp
#include <stdio.h>
#include <iostream>
#include "FunctionPointer.hpp"
void func1();
void func2();
void (*m_pFunc)() = func1;
int main() {
printf("function1()\n");
m_pFunc();
m_pFunc = func2;
m_pFunc();
printf("function2()\n");
void (*pFunc)() = func1;
pFunc();
pFunc = func2;
pFunc();
FunctionPointer fp;
printf("cs.run1()\n");
fp.run1();
printf("cs.run2()\n");
fp.run2();
}
void func1() {
printf(" void func1()\n");
}
void func2() {
printf(" void func2()\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment