Created
November 22, 2015 14:10
-
-
Save yasuakiohama/da6b8cbf42ae5a7760ad to your computer and use it in GitHub Desktop.
FunctionPointerMain.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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