您的位置:首页 > 其它

函数的参数的默认值

2016-12-17 13:49 134 查看
A  default argument shall not be redefined by a later declaration (not even to the same value)

#include<iostream>
using namespace std;

void print(double area = 2);

int main(){
print();
print(4);
system("pause");
return 0;
}

void print(double area = 1){
cout<<area;
}

上面代码只能修改成下面的样子才可以:
#include<iostream>
using namespace std;

void print(double area = 2);

int main(){
print();
print(4);
system("pause");
return 0;
}

void print(double area){
cout<<area;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: