-
大小: 2.96KB文件類型: .zip金幣: 1下載: 0 次發(fā)布日期: 2021-02-21
- 語言: C/C++
- 標(biāo)簽:
資源簡介
C++實(shí)戰(zhàn)源碼-const函數(shù)的使用(入門級實(shí)例221).zip
代碼片段和文件信息
//?constFunction.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include
using?namespace?std;
class?Man //聲明一個(gè)Man類
{
private:
int?m_height;
int?m_weight;
public:
Man(int?hint?w);
void?display()const; //聲明一個(gè)常成員函數(shù)
};
Man::Man(int?h?int?w)
{
m_height=h;
m_weight=w;
}
void?Man::display()const //定義常成員函數(shù),在其中引用成員變量
{
cout<<“the?height?of?man?is?:“< cout<<“the?weight?of?man?is?:“< }
int?main()
{
Man?man(170120); //定義一個(gè)Man類的對象
man.display(); //通過這個(gè)對象調(diào)用常成員函數(shù)
return?0;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????????673??2010-10-14?17:59??constFunction\constFunction.cpp
?????文件????????4620??2010-10-14?17:59??constFunction\constFunction.dsp
?????文件?????????551??2010-10-14?17:59??constFunction\constFunction.dsw
?????文件?????????300??2010-10-14?17:59??constFunction\StdAfx.cpp
?????文件?????????769??2010-10-14?17:59??constFunction\StdAfx.h
評論
共有 條評論