資源簡介
C++實戰源碼-編寫同名的方法(入門級實例206).zip
代碼片段和文件信息
//?OverloadFunction.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“iostream.h“
class?OverloadingFunction?{
public:
void?info()?{//定義沒有參數的info()方法
????????cout?<“普通方法:1“?<????}
????void?info(int?age)?{//定義包含整型參數的info()方法
????????cout?<“重載方法:“?<????}
};
int?main(int?argc?char*?argv[])
{
OverloadingFunction?*ot?=?new?OverloadingFunction();//創建OverloadingTest類對象
ot->info();//測試無參數info()方法
for?(int?i?=?1;?i?5;?i++)?{//測試有參數info()方法
ot->info(i);
}
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????624??2010-10-13?18:49??OverloadFunction\OverloadFunction.cpp
?????文件????????4656??2010-10-13?18:45??OverloadFunction\OverloadFunction.dsp
?????文件?????????557??2010-10-13?18:45??OverloadFunction\OverloadFunction.dsw
?????文件?????????303??2010-10-13?18:45??OverloadFunction\StdAfx.cpp
?????文件?????????769??2010-10-13?18:45??OverloadFunction\StdAfx.h
評論
共有 條評論