This commit is contained in:
Light-City
2019-11-05 16:56:07 +08:00
parent 3a495d7fa2
commit 8edbbbc5a2
179 changed files with 428 additions and 26 deletions

BIN
basic_content/func_pointer/func1 Executable file

Binary file not shown.

View File

@@ -0,0 +1,33 @@
/**
* @file func_pointer.cpp
* @brief 函数指针的使用!
* @author 光城
* @version v1
* @date 2019-07-20
*/
#include<iostream>
using namespace std;
/**
* @brief 定义了一个变量pFun这个变量是个指针指向返回值和参数都是空的函数的指针
*/
void (*pFun)(int);
/**
* @brief 代表一种新类型不是变量所以与上述的pFun不一样
*/
typedef void (*func)(void);
void myfunc(void)
{
cout<<"asda"<<endl;
}
void glFun(int a){ cout<<a<<endl;}
int main(){
func pfun = myfunc;/*赋值*/
pfun();/*调用*/
pFun = glFun;
(*pFun)(2);
}