//C++可以声明占位符参数,占位符参数一般用于程序扩展和对C代码的兼容
int func(int a, int b, int = 0)
{
return a + b;
}
void main()
{
//如果默认参数和占位参数在一起,都能调用起来
func(1, 2);
func(1, 2, 3);
system("pause");
}
void myPrint(int x = 3)
{
printf("x:%d", x);
}
//默认参数
void printAB(int x = 3)
{
printf("x:%d\n", x);
}
//在默认参数规则 ,如果默认参数出现,那么右边的都必须有默认参数
void printABC(int a, int b, int x = 3, int y=4, int z = 5)
{
printf("x:%d\n", x);
}
int main(int argc, char *argv[])
{
printAB(2);
printAB();
system("pause");
return 0;
}
void myPrint(int x = 3)
{
printf("x:%d", x);
}
//默认参数
void printAB(int x = 3)
{
printf("x:%d\n", x);
}
//在默认参数规则 ,如果默认参数出现,那么右边的都必须有默认参数
void printABC(int a, int b, int x = 3, int y=4, int z = 5)
{
printf("x:%d\n", x);
}
int main(int argc, char *argv[])
{
printAB(2);
printAB();
system("pause");
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有