C++ 函数参数的默认值

#include<iostream>
using namespace std;

int get(int a=10)
{
    return a;
}
double get_cycle_area(double r,double pi=3.1415)
{
    return pi*r*r;
}
double get_cycle_area(double d)
{
    return 3.1415*(d/2)*(d/2);
}

int main()
{
    int m=get();
    cout<<get_cycle_area(1.0)<<endl;
    cout<<get_cycle_area(2.0)<<endl;
    cout<<get_cycle_area(3.0,3.1415926)<<endl;
//  cout<<m<<endl;
}
posted @ 2016-03-30 10:15  夜色下的港湾  Views(97)  Comments(0Edit  收藏  举报