您的位置:首页 > 编程语言 > C语言/C++

C++成员函数缺省参数 示例

2011-04-05 13:27 183 查看
/*******************************************************
 *author:PengXiaoLin
 *copyright: 版权所有,翻版不究】
 *function: 成员函数缺省参数测试
 ******************************************************/

#include <iostream>
#include <string>

using namespace std;

class DfaultTest
{
 public:
  void test(int a = 10, int b = 20);
};

int main()
{
 DfaultTest a;

 /*函数缺省参数测试*/
 cout<<"调用缺省参数:/n";
 a.test();
 cout<<"指定参数:/n"; 
 a.test(23, 12);
 
 while(1);
}

void DfaultTest::test(int a, int b)
{
 cout<<"a = "<<a<<"/n";
 cout<<"b = "<<b<<"/n"; 
}
s
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c++ 测试 function
相关文章推荐