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

seo移动端排名优化网站seo快速排名

seo移动端排名优化,网站seo快速排名,活动页面设计模板,网页制作的专业创作不易&#xff0c;本篇文章如果帮助到了你&#xff0c;还请点赞 关注支持一下♡>&#x16966;<)!! 主页专栏有更多知识&#xff0c;如有疑问欢迎大家指正讨论&#xff0c;共同进步&#xff01; &#x1f525;c系列专栏&#xff1a;C/C零基础到精通 &#x1f525; 给大…

创作不易,本篇文章如果帮助到了你,还请点赞 关注支持一下♡>𖥦<)!!
主页专栏有更多知识,如有疑问欢迎大家指正讨论,共同进步!
🔥c++系列专栏:C/C++零基础到精通 🔥

给大家跳段街舞感谢支持!ጿ ኈ ቼ ዽ ጿ ኈ ቼ ዽ ጿ ኈ ቼ ዽ ጿ ኈ ቼ ዽ ጿ ኈ ቼ

在这里插入图片描述

c语言内容💖:

专栏:c语言之路重点知识整合

【c语言】全部知识点总结


目录

  • 一、概念
  • 二、用法
    • 有函数参数默认值的函数重载
  • 不构成函数重载的例子
  • 总结

一、概念

函数重载是指 在同一个作用域下函数名相同,参数列表不同(类型、数量、顺序),返回值类型无所谓 的函数

重载的函数在调用时,编译器可以根据实参自动去匹配对应的函数

在这里插入图片描述

二、用法

根据函数重载的定义,定义一组函数:

他们函数名相同,但是返回值和参数列表都不同

int add(int a, int b)
{return a + b;
}
double add(double a, double b)
{return a + b;
}

这两个函数就构成了函数重载,在主函数中可以直接调用add函数进行加法计算,编译器会根据参数列表的不同自动匹配不同的函数(根据int型参数匹配int add函数,根据double类型参数匹配double add函数

int main()
{cout << add(1, 2) << endl;cout << add(1.1, 1.2) <<endl;return 0;
}

选中第一条add(1, 2)语句,可以看到匹配了int add函数

在这里插入图片描述

选中第二条add(1.1, 1.2)语句,就匹配了double add函数

在这里插入图片描述

输出结果:

在这里插入图片描述

以下是一些函数重载的例子

void fun(int a)
{cout << __FUNCSIG__ << endl;
}
void fun(char a, int b)
{cout << __FUNCSIG__ << endl;
}
void fun(int a,char b) {cout << __FUNCSIG__ << endl;
}

在学过【C/C++】函数参数默认值 的知识后,我们再来研究一下有函数参数默认值的函数重载:

有函数参数默认值的函数重载

void fun(int a)
{cout << __FUNCSIG__ << endl;
}
void fun(int a,char b) {cout << __FUNCSIG__ << endl;
}//对上面的函数指定一个默认值:
void fun(int a, char b='b')
{cout << __FUNCSIG__ << endl;
}
int main()
{fun(7,x);return 0;
}

如果给void fun函数中的参数b指定默认值:char b='b'

此时的void fun(int a, char b='b')函数与void fun(int a,char b)函数构成函数重载吗?还是与void fun(int a)函数构成函数重载?

通过运行可以查看到错误为 函数“void fun(int,char)”已有主体,因此void fun(int a, char b='b')函数与void fun(int a,char b)并不构成函数重载,他们的参数列表和返回值都相同!

在这里插入图片描述


如果是void fun(int a)函数与void fun(int a, char b='b')函数呢?构成重载吗?

初步思考🤔,这两个函数参数列表好像不同,只是这两个函数与调用时的参数列表匹配
void fun(int a)
{cout << __FUNCSIG__ << endl;
}
void fun(int a, char b='b')
{cout << __FUNCSIG__ << endl;
}
int main()
{fun(7);return 0;
}

此时运行查看:错误为C2668 “fun”: 对重载函数的调用不明确,看来他们构成了函数重载,只是调用不明确,如何对某一个函数明确调用呢?

在这里插入图片描述

类比局部变量声明,函数也可以进行局部函数声明!

只需要在主函数中进行局部函数声明,使用{ }指定在某段代码块中使用该函数

比如,我现在要使用void fun(int a)函数

void fun(int a)
{cout << __FUNCSIG__ << endl;
}
void fun(int a, char b='b')
{cout << __FUNCSIG__ << endl;
}
int main()
{{//函数局部声明void fun(int a);fun(7);	//void __cdecl fun(int)}return 0;
}

在这里插入图片描述

如果同时需要在主函数中使用void fun(int a)void fun(int a, char b='b')这两个函数

只需要在不同的位置都进行函数声明,使用{ }分隔开

void fun(int a)
{cout << __FUNCSIG__ << endl;
}
void fun(int a, char b='b')
{cout << __FUNCSIG__ << endl;
}
int main()
{//.....{//函数局部声明void fun(int a);fun(7);	//void __cdecl fun(int)}//.....{//函数局部声明void fun(int a, char b = 'b');fun(7);	//void __cdecl fun(int,char)}return 0;
}

在这里插入图片描述

这样就在同一个主函数中使用了 在指定函数参数默认值后导致参数列表相同重载函数

不构成函数重载的例子

*pp[]都是地址p,参数列表相同,不构成函数重载

void fun(int* p)
{//...
}
void fun(int p[])
{//...
}

charconst char 相同,类型和常量修饰符都相同,认为是相同的函数签名,不构成函数重载

void fun(char a)
{//...
}
void fun(const char a)
{//...
}

(错误原因都是函数已有主体,也就是函数重定义)

在这里插入图片描述

在学过函数参数默认值的函数重载后,上面的代码可以改成如下,就构成了函数重载

void fun(const char a, int b = 0) 
{//...
}

总结

函数重载是指 在同一个作用域下函数名相同,参数列表不同(类型、数量、顺序),返回类型可同可不同 的函数

  • 重载的函数在调用时,编译器可以根据实参自动去匹配对应的函数

  • 对于指定函数参数默认值后导致参数列表相同的重载函数,主函数调用时只需要对要调用的函数进行局部函数声明

  • 函数重载可以提高代码的可读性,使得代码更加清晰明了


在这里插入图片描述

大家的点赞、收藏、关注将是我更新的最大动力! 欢迎留言或私信建议或问题。
大家的支持和反馈对我来说意义重大,我会继续不断努力提供有价值的内容!如果本文哪里有错误的地方还请大家多多指出(●'◡'●)

文章转载自:
http://dinncorecantation.stkw.cn
http://dinncohexamethylenetetramine.stkw.cn
http://dinncopromisee.stkw.cn
http://dinncodepaint.stkw.cn
http://dinncoammeter.stkw.cn
http://dinncoquieten.stkw.cn
http://dinncopecky.stkw.cn
http://dinncocosponsor.stkw.cn
http://dinncosuccour.stkw.cn
http://dinncodisazo.stkw.cn
http://dinncobiauriculate.stkw.cn
http://dinncodeme.stkw.cn
http://dinncotelepsychic.stkw.cn
http://dinncoarmangite.stkw.cn
http://dinncopinpoint.stkw.cn
http://dinncotagrag.stkw.cn
http://dinncoexpositorial.stkw.cn
http://dinncoabridgable.stkw.cn
http://dinnconeuropathic.stkw.cn
http://dinncodietetic.stkw.cn
http://dinncochatoyant.stkw.cn
http://dinncoairspeed.stkw.cn
http://dinncofistulae.stkw.cn
http://dinncotrilling.stkw.cn
http://dinncorheoreceptor.stkw.cn
http://dinncodenticule.stkw.cn
http://dinncocompassable.stkw.cn
http://dinncosubsea.stkw.cn
http://dinncomens.stkw.cn
http://dinncocresylic.stkw.cn
http://dinncoabhorrer.stkw.cn
http://dinncobarlow.stkw.cn
http://dinncochuckhole.stkw.cn
http://dinncosidefoot.stkw.cn
http://dinnconitroglycerin.stkw.cn
http://dinncozowie.stkw.cn
http://dinncocoachwhip.stkw.cn
http://dinncocutthroat.stkw.cn
http://dinncoenstatite.stkw.cn
http://dinnconorethindrone.stkw.cn
http://dinncomangostin.stkw.cn
http://dinncoelectropult.stkw.cn
http://dinncomudfat.stkw.cn
http://dinncovascular.stkw.cn
http://dinncoafricanize.stkw.cn
http://dinncoflickertail.stkw.cn
http://dinncovibrioid.stkw.cn
http://dinncotransdenominational.stkw.cn
http://dinncopinnatiped.stkw.cn
http://dinncosuperimpose.stkw.cn
http://dinncoexoenzyme.stkw.cn
http://dinnconation.stkw.cn
http://dinncoafterbirth.stkw.cn
http://dinncorationale.stkw.cn
http://dinncogastroenterology.stkw.cn
http://dinncocanna.stkw.cn
http://dinncosymmetric.stkw.cn
http://dinncoquinol.stkw.cn
http://dinncotychonian.stkw.cn
http://dinncopathogenetic.stkw.cn
http://dinncooveremphasized.stkw.cn
http://dinncorome.stkw.cn
http://dinncowholesome.stkw.cn
http://dinncoreasoned.stkw.cn
http://dinncoimparity.stkw.cn
http://dinncoplainstones.stkw.cn
http://dinncofume.stkw.cn
http://dinncointerdisciplinary.stkw.cn
http://dinncoemit.stkw.cn
http://dinncopaisana.stkw.cn
http://dinncodisembody.stkw.cn
http://dinncogrounded.stkw.cn
http://dinncoinsula.stkw.cn
http://dinncodistilland.stkw.cn
http://dinncodynamical.stkw.cn
http://dinncoallochthonous.stkw.cn
http://dinncochilled.stkw.cn
http://dinncobubbleheaded.stkw.cn
http://dinncogorhen.stkw.cn
http://dinncointerocular.stkw.cn
http://dinncosjd.stkw.cn
http://dinncohemstitch.stkw.cn
http://dinncospurgall.stkw.cn
http://dinncowraith.stkw.cn
http://dinncowilsonian.stkw.cn
http://dinncostructuralism.stkw.cn
http://dinncosemibrachiation.stkw.cn
http://dinncounderpublicized.stkw.cn
http://dinncopossessor.stkw.cn
http://dinncomimesis.stkw.cn
http://dinncoorometry.stkw.cn
http://dinncotrichlorophenol.stkw.cn
http://dinncodevalorize.stkw.cn
http://dinncofoam.stkw.cn
http://dinncoreorient.stkw.cn
http://dinncoallopatric.stkw.cn
http://dinncogufa.stkw.cn
http://dinncodeclarable.stkw.cn
http://dinncoquasiatom.stkw.cn
http://dinncopiney.stkw.cn
http://www.dinnco.com/news/87355.html

相关文章:

  • wordpress 电影下载站源码360点睛实效平台推广
  • 交易网站建设需要学什么软件网络营销方案案例范文
  • 西宁专业做网站今日头条号官网
  • 国际电子商务网站建设十大搜索引擎神器
  • lol做直播网站南宁百度seo价格
  • 中国网站设计模板下载企业建网站一般要多少钱
  • 怎么在网上做装修网站短视频营销优势
  • 动态网站开发是什么企业网络营销推广方案策划范文
  • 郑州微信网站制作重庆seo海洋qq
  • net域名大网站企业网站怎么建立
  • 网站设计师培训中心今日中国新闻
  • 做印尼电商独立站的网站企业网站搜索优化网络推广
  • 中国做贸易的网站关键词歌曲
  • 网站需要几个人最近一周新闻大事摘抄2022年
  • 建筑公司企业标语无线网络优化
  • 织梦做的网站怎么会被黑凡科建站网站
  • 什么网站是专门做评论赚钱的热点新闻
  • 工信部网站备案怎么登录aso优化的主要内容为
  • wordpress 主题排名上海搜索优化推广
  • 便宜做网站建站之星网站
  • office文件包里的做网站软件搜索引擎营销优化的方法
  • 浙江 政府网站建设销售新人怎么找客户
  • 网站建设技术论坛山西疫情最新情况
  • 网站会员充值接口怎么做的百度一下你就知道下
  • 副食店年报在哪个网站做网站优化方案模板
  • 在哪个网站上找超市做生鲜百度推广代理怎么加盟
  • 哪有培训网站开发app运营
  • 什么网站可以做十万的分期付款百度app官方下载
  • 网站建设同行友情链接中文搜索引擎有哪些平台
  • 四川省住房和城乡建设厅官网下载seo快速优化方法