函数指针Function Pointer
来源:互联网 发布:python split函数用法 编辑:程序博客网 时间:2024/05/29 13:47
今天想系统的学习一下函数指针机器用法
资料来源http://www.newty.de/fpt/index.html
《The Function Pointer Tutorials》 written by Lars Haendel2005
一、Introduce
You can use them to replace switch/case statement,to realize your own late-binding or to implement callbacks
二、The Syntax of C and C++ Function Pointer
There are two different types of fuction pointer:On the one hand there are pointer to ordinary C functions or static C++ member fuctions ,On the other hand there are pointers to non-static C++ member functions.The basic difference is that the pointers to non-static C++ memeber functions need a hidden argument: The this-pointer to an instance of the class. Always keep in mind that:This two kinds of function pointer are incompatible with each other.
三、How to return a function pointer
a、Direct Solution
//“Plus ”and "Minit" are two defined Functions that return float and
//take two float
float (*GetPtr(const char optc))(float,float)
{
if(optc=='+')
return Plus;
else
return Minit;
}
b、Solution using typedef
typedef float (*pt2Fuc)(float ,float);
pt2Fun Getprt(const char optc)
{ if(optc=='+') return Plus; else return Minit; }
- 函数指针Function Pointer
- 函数指针 Function Pointer
- function pointer(函数指针)
- Function pointer - 函数指针
- Pointer function - 指针函数
- 函数指针(function pointer)
- 函数指针(function pointer)
- 079.Pointer Function 指向函数的指针
- 079.Pointer Function 指向函数的指针
- 指向函数的指针 ------ 函数指针(function pointer)
- 080.Function Pointer Arg 函数指针作为函数参数
- 080.Function Pointer Arg 函数指针作为函数参数
- C++ 成员函数指针的问题 pointer-to-member-function
- 081.Return Pointer Function 返回指针的函数
- 081.Return Pointer Function 返回指针的函数
- Function Pointer of class member function (类的成员函数指针)
- Function Pointer of class member function C++的类成员函数指针简要
- Function Pointer of class member function (类的成员函数指针)
- 深入介绍libevent跨平台事件驱动库
- Android中在屏幕上涂鸦的例子
- Android 开发环境的搭建之Linux
- 什么叫牛B,这个渲染的很精彩
- BlackBerry 蓝牙编程(二)
- 函数指针Function Pointer
- C#使用XmlEDocument实现数据文件安全存储功能
- 解决SharePoint中GridView导出Excel按钮的问题
- C++应该支持分离声明类
- Web开发必知的八种隔离级别
- GameJS——Game Library written in JavaScript
- C# WinForm打开PDF文件
- 图
- 什么叫内连接、外连接、左连接、右连接