当前位置:网站首页>Function and usage of function pointer
Function and usage of function pointer
2022-07-05 07:38:00 【Code boy】
1、 Function pointer function :
The advantage of using function pointers is that , Multiple modules that realize the same function can be identified together , This makes it easier
Easy for later maintenance , The system structure is clearer . Or summed up as : Easy to layer design 、 It's good for system abstraction 、 Reduce coupling and separate the interface from the implementation .
#include <iostream>
using namespace std;
int arr(int a, int b) {
return 0; }
int brr(int a, int b) {
return 1; }
int main()
{
int (*frr)(int, int);// Here is the function pointer
frr = arr;// It can point to arr
cout << frr(1, 2) << endl;
frr = brr; You can also point to brr, Just change the object pointed to , You can operate different functions
cout << frr(1, 2) << endl;
return 0;
}
C/C++ Function pointer Usage Summary :https://www.cnblogs.com/lvchaoshun/p/7806248.html
边栏推荐
- CADD课程学习(5)-- 构建靶点已知的化合结构(ChemDraw)
- Rough notes of C language (1)
- Self summary of college life - freshman
- Graduation thesis project local deployment practice
- Day08 ternary operator extension operator character connector symbol priority
- Basic series of SHEL script (I) variables
- UNIX commands often used in work
- deepin 20 kivy unable to get a window, abort
- Apple modify system shortcut key
- Web page Chinese display (print, etc.) GBK error, solution, software
猜你喜欢
Build your own random wallpaper API for free
Delayqueue usage and scenarios of delay queue
Light up the running light, rough notes for beginners (1)
大学生活的自我总结-大一
Self summary of college life - freshman
How to deal with excessive memory occupation of idea and Google browser
CADD course learning (6) -- obtain the existing virtual compound library (drugbank, zinc)
QT small case "addition calculator"
UE5热更新-远端服务器自动下载和版本检测(SimpleHotUpdate)
Matrix and TMB package version issues in R
随机推荐
Detour of Tkinter picture scaling
The sublime version that XP can run is 3114
Idea shortcut key
Daily Practice:Codeforces Round #794 (Div. 2)(A~D)
Typecho adds Baidu collection (automatic API submission plug-in and crawler protocol)
golang定时器使用踩的坑:定时器每天执行一次
Numpy——1.数组的创建
Selenium element positioning
What is Bezier curve? How to draw third-order Bezier curve with canvas?
UE5热更新-远端服务器自动下载和版本检测(SimpleHotUpdate)
大学生活的自我总结-大一
list. files: List the Files in a Directory/Folder
Reading literature sorting 20220104
CADD course learning (5) -- Construction of chemosynthesis structure with known target (ChemDraw)
The golang timer uses the stepped pit: the timer is executed once a day
Hdu1231 maximum continuous subsequence (divide and conquer or dynamic gauge or double pointer)
Simple operation of running water lamp (keil5)
Microservice registry Nacos introduction
Play with grpc - go deep into concepts and principles
Differences between pycharm and idle and process -- join() in vs Code