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;
}