函数指针基础语法C++
2018-01-14 19:29
288 查看
//#include "stdafx.h" #include <iostream> using namespace std; int function(int a, int b) { cout << a << " + " << b << " = "; return a + b; } int main() { int (*tp)(int, int); tp = &function; cout << tp(1, 0) << endl; typedef int(type_func)(int, int); type_func *tp1; //定义指向函数的指针 tp1 = &function; //tp1 = function; //or C版本 cout << tp1(1, 1) << endl; typedef int(*type_p_func)(int, int); type_p_func tp2; tp2 = &function; cout << tp2(1, 2) << endl; system("pause"); return 0; }
相关文章推荐
- c++基础语法(构造函数初始化列表)
- C++学习笔记:函数指针语法基础以及函数指针做函数参数的思想剖析
- c++基础语法(构造函数初始化列表)
- c++基础语法(构造函数初始化列表)
- CSS 基础语法
- lua中的特殊语法,较基础
- Linux脚本编写语法基础
- [正则表达式]-基础语法四 元字符优先级
- python学习基础linux基本语法3
- mysql基础语法神马滴...
- JSP基础语法
- C#语法基础
- Gradle基础之Groovy语法
- C++基础语法
- MySQL基础知识---------CREATE INDEX语法
- Objective-C 基础知识之 (十四):属性 Property 点语法
- jsp基础语法一:
- Java Web学习总结(14)——JSP基础语法
- JavaScript-语法基础
- 英语基础语法(五)-形容词、副词