-
大小: 2.84KB文件類型: .zip金幣: 1下載: 0 次發(fā)布日期: 2021-02-21
- 標(biāo)簽:
資源簡(jiǎn)介
C++實(shí)戰(zhàn)源碼-重寫父類中的方法(入門級(jí)實(shí)例212).zip
代碼片段和文件信息
//?Override.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“iostream.h“
class?Employee?{
public:
char?*?getInfo()?{//定義測(cè)試用的方法
????????return?“父類:我是明日科技的員工!“;
????}
};
class?Manager?:?public?Employee?{
public:
char*?getInfo()?{//重寫測(cè)試用的方法
????????return?“子類:我是明日科技的經(jīng)理!“;
????}
};
int?main(int?argc?char*?argv[])
{
Employee?employee; //創(chuàng)建Employee對(duì)象
cout?< Manager?manager; //創(chuàng)建Manager對(duì)象
cout?<
return?0;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????????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
評(píng)論
共有 條評(píng)論