博客
关于我
函数的默认参数值,即在定义参数的时候给它一个默认值
阅读量:306 次
发布时间:2019-03-04

本文共 728 字,大约阅读时间需要 2 分钟。

 

int add(int a,int b=2,int c =4);
  • 1

其中有两个规定

1.如果某个参数是默认参数,那么它后面的参数必须是默认参数

2.默认参数可以放在声明、或者定义中,但是只能二者选一

以上是网上看的一个帖子:但是自己ubuntu18.04,g++编译的时候,必须把默认形参放在声明中,

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;void biggies(vector
& words,vector
::size_type sz,ostream & os=cout , //;默认形参char c = ' ' );                     //默认形参int main(){ vector
vstr{"1","2","33","444","555","6666","77777","88888","89999","00000"}; biggies(vstr,100); return 0;}void biggies(vector
&words,vector
::size_type sz,ostream &os,char c){ for_each(words.begin(),words.end(),[&os,c](const string &s){os << s << c;});}

 

转载地址:http://dgpq.baihongyu.com/

你可能感兴趣的文章
asp.net代码练习 work016 fileupload文件上传
查看>>
asp.net代码练习 work021 DataReader的使用
查看>>
PHP7.0--如何使用函数的引用
查看>>
Java基础--01--数据类型/方法/数组
查看>>
【JokerのZYNQ7020】LINUX_EMIO_LED。
查看>>
【JokerのZYNQ7020】LINUX_EMIO_BUTTON。
查看>>
vim匹配特定的行并删除
查看>>
读取excel文件错误
查看>>
傅里叶变换的初级理解三
查看>>
F1 score的意义
查看>>
python36+centos7离线安装tensorflow与talib的方法
查看>>
hdf5与hdfs的区别
查看>>
scala运行的方式
查看>>
tf.Session().as_default的作用
查看>>
isnull与isna的区别
查看>>
python自带超参调优包
查看>>
判断python模型是否安装的办法
查看>>
xgboost与gbdt的区别
查看>>
软件测试中使用coverage统计python代码的覆盖率
查看>>
从double到float的强制类型转换
查看>>