資源簡介
C++實戰源碼-重寫父類中的方法(入門級實例212).zip
代碼片段和文件信息
//?Override.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“iostream.h“
class?Employee?{
public:
char?*?getInfo()?{//定義測試用的方法
????????return?“父類:我是明日科技的員工!“;
????}
};
class?Manager?:?public?Employee?{
public:
char*?getInfo()?{//重寫測試用的方法
????????return?“子類:我是明日科技的經理!“;
????}
};
int?main(int?argc?char*?argv[])
{
Employee?employee; //創建Employee對象
cout?< Manager?manager; //創建Manager對象
cout?<
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????680??2010-10-14?10:20??Override\Override.cpp
?????文件????????4560??2010-10-14?10:15??Override\Override.dsp
?????文件?????????541??2010-10-14?10:15??Override\Override.dsw
?????文件?????????295??2010-10-14?10:15??Override\StdAfx.cpp
?????文件?????????769??2010-10-14?10:15??Override\StdAfx.h
- 上一篇:C++實戰源碼-用指針實現逆序存放數組元素值
- 下一篇:C++實戰源碼-員工間的差異
評論
共有 條評論