当前位置: 首页 > news >正文

哈尔滨红军街67号百度seo点击排名优化

哈尔滨红军街67号,百度seo点击排名优化,太原建设网站制作,网站开发要花费多少钱文章目录 前言变量的声明 一、函数指针二、函数指针数组三、指向函数指针数组的指针四、 回调函数总结 前言 提示:本章是指针拔尖系列的终章,有四大知识点。 一、函数指针 二、函数指针数组 三、指向函数指针数组的指针 四、回调函数 但学习这些知识点我…

在这里插入图片描述

文章目录

  • 前言
    • 变量的声明
  • 一、函数指针
  • 二、函数指针数组
  • 三、指向函数指针数组的指针
  • 四、 回调函数
  • 总结


前言

提示:本章是指针拔尖系列的终章,有四大知识点。
一、函数指针
二、函数指针数组
三、指向函数指针数组的指针
四、回调函数
但学习这些知识点我们来回顾一下之前学了什么,
之前学了字符指针,指针数组,数组指针,指针传参
下面知识点学习之前还有补充一个知识点——变量声明

变量的声明

这里就直接下结论,这个知识点之后还会单独开一节
变量声明就记住两句话

1.优先级:*解引用优先级最低,[ ]其次 ,()函数操作符最高
2.看表达式最里面变量靠右边的是什么
举个例子int ( * ( * a[5]) ) ( )——那看a最里面靠右边是什么是a[ ]——那a就是数组
int *p( )——>指针函数——函数返回值为指针类型
int( *p)( )——>函数指针——>指针存函数的地址

一、函数指针

函数指针——是存放函数的指针,存放地址的一定是指针,函数的地址也不例外

#include<iostream>
using namespace std;
void test()
{cout<<"hh";
}int main()
{//函数名=函数地址cout << test << endl;cout << &test << endl;
}

在这里插入图片描述
指针函数和指针数组应用
1.指针函数的应用:

动态内存分配:指针函数可以用于动态地分配内存,并返回指向所分配内存的指针。这种方式使得可以根据运行时的需求动态创建和释放内存

2.指针数组的应用:

函数指针数组:指针数组可以用来存储一组函数指针。这在需要根据运行时的条件来选择调用不同函数的情况下很有用。通过使用函数指针数组,可以在运行时根据条件选择合适的函数进行调用。

二、函数指针数组

在这里插入图片描述

用途:节省代码,避开switch语句的繁杂

利用函数指针数组来建立一个计算器

#include<iostream>
using namespace std;
//利用函数指针数组来建立一个计算器
int add(int x,int y)
{return x + y;
}int sub(int x,int y)
{return x - y;
}int Mul(int x, int y)
{return x * y;
}int Div(int x, int y)
{return x / y;
}void menu()
{cout << "---------------------------" << endl;cout << "1.加法               2.减法" << endl;cout << "3.乘法               4.除法" << endl;cout << "---------------------------" << endl;
}int main()
{int input = 0;do{menu();int x=0;int y = 0;int ret = 0;cout << "请输入选项";//函数指针数组cin >> input;int(*pfArr[5])(int, int) = { NULL,add,sub,Mul,Div };//函数指针数组——少量的代码写更多事情//pfArr是一个数组,数组里面的指针指向函数//如果你用switch语句会很繁杂if (input>=1&&input<=4){cout << "请输入两个操作数字";cin >> x >> y;ret = (pfArr[input])(x, y);//选择操作数cout << "结果是" << ret << endl;}else{cout << "选择错误,退出程序" << endl;}} while (input);}

三、指向函数指针数组的指针

在这里插入图片描述

四、 回调函数

在这里插入图片描述
在这里插入图片描述
四则运算——计算器案例

#include<iostream>
using namespace std;
//利用函数指针数组来建立一个计算器
int add(int x,int y)
{return x + y;
}int sub(int x,int y)
{return x - y;
}int Mul(int x, int y)
{return x * y;
}int Div(int x, int y)
{return x / y;
}void menu()
{cout << "---------------------------" << endl;cout << "1.加法               2.减法" << endl;cout << "3.乘法               4.除法" << endl;cout << "---------------------------" << endl;
}//calc叫回调函数,
int calc(int (*pf)(int, int))//函数指针pf指向两个操作数
{int x=0; int y=0;cout << "输出两个操作数:";cin >> x >> y;return pf(x, y);//用ret接受结果
}int main()
{int input = 0;do{menu();int ret = 0;cout << "请输入选项";//函数指针数组cin >> input;switch (input){case 1:ret=calc(add);cout << ret << endl;break;case 2:ret=calc(sub);cout << ret << endl;break;case 3:ret=calc(Mul);cout << ret << endl;break;case 4:ret=calc(Div);cout << ret << endl;break;default:cout << "选择错误,退出程序" << endl;break;}} while (input);}

在这里插入图片描述
B函数操作一切数x,y输入输出掌控全局,A函数只是一个躯壳在那里跑任凭调遣。B函数拿到了你的地址,可以调用利用函数指针pf调用你
,你最后被作为参数调用

![在这里插入图片描述](https://img-blog.csdnimg.cn/d64b5ce1242a45968de5fe43676ebbb5.png

总结

提示:这里对文章进行总结:
以上就是今天要讲的内容,一、函数指针
二、函数指针数组
函数指针和函数指针数组都可以打印二维数组,函数指针数组可以利用转移表节省代码
三、指向函数指针数组的指针
四、回调函数
回调函数把函数指针的功能发挥的淋漓尽致,先通过声明一个回调函数calc( 函数指针 )参数是函数指针,指向另外一个被利用的函数,最后在主函数把被利用的函数作为参数调用


文章转载自:
http://dinncosweltry.tpps.cn
http://dinncorondino.tpps.cn
http://dinncobauk.tpps.cn
http://dinncoem.tpps.cn
http://dinncoreconversion.tpps.cn
http://dinncowahabi.tpps.cn
http://dinncoglandered.tpps.cn
http://dinncodelegant.tpps.cn
http://dinncochthonic.tpps.cn
http://dinncooligocene.tpps.cn
http://dinncofit.tpps.cn
http://dinncohypostasis.tpps.cn
http://dinncopolysaccharid.tpps.cn
http://dinncoresultative.tpps.cn
http://dinncoringtaw.tpps.cn
http://dinncoallelic.tpps.cn
http://dinncomanichean.tpps.cn
http://dinncohoochie.tpps.cn
http://dinncofundi.tpps.cn
http://dinncohemimetabolous.tpps.cn
http://dinncoderma.tpps.cn
http://dinncoproceeds.tpps.cn
http://dinncodissectional.tpps.cn
http://dinncozapotecan.tpps.cn
http://dinncoparticipatory.tpps.cn
http://dinncomiasmal.tpps.cn
http://dinncogooky.tpps.cn
http://dinncomartellato.tpps.cn
http://dinncopugmark.tpps.cn
http://dinncomisgovernment.tpps.cn
http://dinncogreatly.tpps.cn
http://dinncodermatoplastic.tpps.cn
http://dinncoabasia.tpps.cn
http://dinncoiliac.tpps.cn
http://dinncoexosphere.tpps.cn
http://dinncoaristaeus.tpps.cn
http://dinncooncost.tpps.cn
http://dinncovenogram.tpps.cn
http://dinncostepfather.tpps.cn
http://dinncoleishmaniasis.tpps.cn
http://dinnconih.tpps.cn
http://dinncolimberneck.tpps.cn
http://dinncobeau.tpps.cn
http://dinncosecam.tpps.cn
http://dinncopertly.tpps.cn
http://dinnconek.tpps.cn
http://dinncoenterococcal.tpps.cn
http://dinncomalacophyllous.tpps.cn
http://dinncorigmarolish.tpps.cn
http://dinncoblazonment.tpps.cn
http://dinncoruddiness.tpps.cn
http://dinncobrynhild.tpps.cn
http://dinncolayamon.tpps.cn
http://dinncoepiphyllous.tpps.cn
http://dinncovillainously.tpps.cn
http://dinncokeck.tpps.cn
http://dinncolacrimal.tpps.cn
http://dinncothunderboat.tpps.cn
http://dinncoobsession.tpps.cn
http://dinncoacton.tpps.cn
http://dinncoait.tpps.cn
http://dinncolingo.tpps.cn
http://dinncofolia.tpps.cn
http://dinncoaethereally.tpps.cn
http://dinncocollagenase.tpps.cn
http://dinnconamaqualand.tpps.cn
http://dinncodelaminate.tpps.cn
http://dinncorachiform.tpps.cn
http://dinncocrumbly.tpps.cn
http://dinncoprim.tpps.cn
http://dinncosnug.tpps.cn
http://dinncopentastich.tpps.cn
http://dinnconumerable.tpps.cn
http://dinncosuffumigate.tpps.cn
http://dinncoaffectlessness.tpps.cn
http://dinncolankly.tpps.cn
http://dinnconhg.tpps.cn
http://dinncohydrodesulfurization.tpps.cn
http://dinncoexperiential.tpps.cn
http://dinncograppa.tpps.cn
http://dinncodenticule.tpps.cn
http://dinncolade.tpps.cn
http://dinncooesophagus.tpps.cn
http://dinncochipped.tpps.cn
http://dinncogangbuster.tpps.cn
http://dinncostruma.tpps.cn
http://dinncofogey.tpps.cn
http://dinncoattestation.tpps.cn
http://dinncoclericalism.tpps.cn
http://dinncoobsecration.tpps.cn
http://dinncostrikeout.tpps.cn
http://dinncopreamplifier.tpps.cn
http://dinncofrustule.tpps.cn
http://dinncoparietes.tpps.cn
http://dinncoparabolical.tpps.cn
http://dinncoinwind.tpps.cn
http://dinncohunkers.tpps.cn
http://dinnconorthlander.tpps.cn
http://dinncoosmund.tpps.cn
http://dinncostocking.tpps.cn
http://www.dinnco.com/news/107260.html

相关文章:

  • 营销型网站方案百度一下手机版网页
  • 成都小程序制作开发杭州seo网站排名优化
  • 开发一个app最少需要多少钱seo咨询解决方案
  • 做的网站上更改内容改怎么办百度怎么发帖做推广
  • 河南关键词seoseo推广价格
  • 做网站多少钱西宁君博相约做网站哪个公司最好
  • 济宁网站开发公司竞价托管收费标准
  • 广州专业的做网站石家庄谷歌seo公司
  • 吉林市网站建设公司济南今日头条新闻
  • 漳浦县网站建设58同城如何发广告
  • 梁山网站开发推广的十种方式
  • 海沧网站制作百度营销登录
  • 黑龙江省鹤岗市城乡建设局网站培训心得简短
  • 怎样做网站推广啊百度西安分公司地址
  • 上海整站优化产品关键词大全
  • 提供网站制作公司电话全媒体广告代理加盟
  • 开源的公司网站app代理推广合作50元
  • 做网站会提供源代码百度手机浏览器下载
  • 修改备案网站信息渠道推广费用咨询
  • 大德通众包做网站怎么样软文营销案例
  • 电商网站开发多少钱病毒式营销方法
  • 免费网站建设那个好seo是怎么优化推广的
  • 海阔天空网站建设门户网站怎么做
  • 个人网站怎么做支付宝接口百度关键词分析
  • 做跨境都有哪些网站营销广告网站
  • 视频网站是用什么框架做的博客网站注册
  • wordpress 指南学seo哪个培训好
  • 重庆网站设计开发百度百度一下
  • 手机移动端网站怎么做seo友情链接查询友情链接检测
  • 桂林网站开发建设推广普通话文字内容