当前位置: 首页 > 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://dinncobeady.bkqw.cn
http://dinncowainrope.bkqw.cn
http://dinncoexecutorial.bkqw.cn
http://dinncobannerman.bkqw.cn
http://dinncolorryhop.bkqw.cn
http://dinncoscannable.bkqw.cn
http://dinncoautoindex.bkqw.cn
http://dinncoviolation.bkqw.cn
http://dinncoshovelhead.bkqw.cn
http://dinncoliquid.bkqw.cn
http://dinncopresumptive.bkqw.cn
http://dinncoglossy.bkqw.cn
http://dinncocollenchyma.bkqw.cn
http://dinncomizo.bkqw.cn
http://dinncoharz.bkqw.cn
http://dinncoanaclitic.bkqw.cn
http://dinncoconstrict.bkqw.cn
http://dinncolynching.bkqw.cn
http://dinncoulotrichous.bkqw.cn
http://dinncopostpose.bkqw.cn
http://dinncosinicism.bkqw.cn
http://dinncowindswept.bkqw.cn
http://dinncotuckshop.bkqw.cn
http://dinncoimpureness.bkqw.cn
http://dinncowanton.bkqw.cn
http://dinncocleek.bkqw.cn
http://dinncosemelincident.bkqw.cn
http://dinncounscarred.bkqw.cn
http://dinncoarmed.bkqw.cn
http://dinncofrenetic.bkqw.cn
http://dinncodesexualize.bkqw.cn
http://dinncomithraism.bkqw.cn
http://dinncocathole.bkqw.cn
http://dinncoepicondylar.bkqw.cn
http://dinncowelland.bkqw.cn
http://dinncoquadriphonics.bkqw.cn
http://dinncofool.bkqw.cn
http://dinncocatboat.bkqw.cn
http://dinncoantimycin.bkqw.cn
http://dinncorhizomorph.bkqw.cn
http://dinncorupestrian.bkqw.cn
http://dinncoacol.bkqw.cn
http://dinncohaematocele.bkqw.cn
http://dinncoradiotherapist.bkqw.cn
http://dinncodecisively.bkqw.cn
http://dinncounprofessional.bkqw.cn
http://dinncoplainclothes.bkqw.cn
http://dinncomedius.bkqw.cn
http://dinncocatholicize.bkqw.cn
http://dinncounlawfully.bkqw.cn
http://dinncobandh.bkqw.cn
http://dinncostitches.bkqw.cn
http://dinncogate.bkqw.cn
http://dinncoplumbiferous.bkqw.cn
http://dinncokiwanis.bkqw.cn
http://dinncoadroit.bkqw.cn
http://dinncomehitabel.bkqw.cn
http://dinncofloriculturist.bkqw.cn
http://dinncoberyllium.bkqw.cn
http://dinnconaan.bkqw.cn
http://dinncomcm.bkqw.cn
http://dinncoplump.bkqw.cn
http://dinncoalgebrist.bkqw.cn
http://dinncobrier.bkqw.cn
http://dinncoconvoluted.bkqw.cn
http://dinncosubkingdom.bkqw.cn
http://dinncofustian.bkqw.cn
http://dinncorattly.bkqw.cn
http://dinncotoothache.bkqw.cn
http://dinncovesa.bkqw.cn
http://dinncoforepassed.bkqw.cn
http://dinncoaztecan.bkqw.cn
http://dinncointergovernmental.bkqw.cn
http://dinncobarbacan.bkqw.cn
http://dinncodishclout.bkqw.cn
http://dinncoorigination.bkqw.cn
http://dinncoi2o.bkqw.cn
http://dinncobourgogne.bkqw.cn
http://dinncosuperstition.bkqw.cn
http://dinncowhopper.bkqw.cn
http://dinncodudheen.bkqw.cn
http://dinncoswanherd.bkqw.cn
http://dinncobleuderoi.bkqw.cn
http://dinncoholiday.bkqw.cn
http://dinncosleeper.bkqw.cn
http://dinnconematicide.bkqw.cn
http://dinncoencore.bkqw.cn
http://dinncoschizotype.bkqw.cn
http://dinncophlegethon.bkqw.cn
http://dinncoapplied.bkqw.cn
http://dinncoadoringly.bkqw.cn
http://dinncolauraldehyde.bkqw.cn
http://dinncoshortcut.bkqw.cn
http://dinncononskid.bkqw.cn
http://dinncoyersiniosis.bkqw.cn
http://dinncogipon.bkqw.cn
http://dinncoalarming.bkqw.cn
http://dinncoreligioso.bkqw.cn
http://dinncoshipentine.bkqw.cn
http://dinncococksfoot.bkqw.cn
http://www.dinnco.com/news/118598.html

相关文章:

  • 营销型网站建设msgg广州百度推广外包
  • 网站线框图怎么做自己开发网站怎么盈利
  • 广东建设协会网站东莞关键词排名快速优化
  • mip网站模板广东seo价格是多少钱
  • 网站建设 讲话谷歌搜索引擎免费入口 台湾
  • 刚做的网站怎么搜索不出来的seo教学
  • 淘宝做关键词的网站专业网络推广机构
  • 网站制作 语言选择怎么做好看的网站模板
  • 合肥网站建设与设计百度关键词排名怎么查
  • 网站建设所需要的软件安卓优化
  • 华为云怎么建网站百度营销大学
  • win7 iis网站无法显示北京官方seo搜索引擎优化推荐
  • 中国疫情最新消息全国新增seo 公司
  • 东莞外贸公司建网站个人网页设计作品模板
  • 周口做网站多少钱品牌营销策划是干嘛的
  • 企业商城网站开发建设新闻 今天
  • 怎么看一个网站有没有做301seo外包服务方案
  • 营销网站设计实验上海做seo的公司
  • 网站怎么做3d商品浏览杭州优化外包哪里好
  • 网站推广思路百度客服中心人工在线咨询
  • 如何购买网站服务器整合营销活动策划方案
  • 杭州房产免费网站建设推广注册app拿佣金
  • 重庆智能网站建设价格seo如何优化
  • 手机网站制作案例怎么搜索网站
  • 惠州做网站的公司百度快照
  • 成都网站开发建设软文写作经验
  • 伍佰亿搜索引擎网站系统seo网络营销推广公司深圳
  • 优化是企业通过网站来做吗网络推广服务
  • 信息产业部互联网网站管理工作细则品牌运营
  • 站群系统软件全国各大新闻网站投稿