- 10
- 0
- 约13.96万字
- 约 930页
- 2017-03-28 发布于湖南
- 举报
c_lecture
void main(void) { Stu p1,p2; p1.SetStudent(“Li qing”,98,96);//对象置初值 p2.SetStudent(Wang Gang,90,88); //对象置初值 p1.Show();//打印信息 p2.Show();//打印信息 p1.SetName (“Zhao jian”);//重新置p1对象的名字 p1.Show (); cout“p1.Name: ”p1.GetName ()endl;//打印对象的名字 cout“p1.average: ”p1.Average ()endl;//打印对象的成绩 } 成员函数的重载 类中的成员函数与前面介绍的普通函数一样,成员函数可以带有缺省的参数,也可以重载成员函数 。 重载时,函数的形参必须在类型或数目上不同。 class Test{ int x , y; int m, n; public: void Setxy(int a, int b){x=a; y=b;} void Setxy(int a,int b,int c,int d){ x=a;y=b;m=c;n=d;} void Printxy(int x){cout “m=m\t“n=nendl;}
您可能关注的文档
- asm及遗传算法在地下水资源量评价中的应用.ppt
- astudyonthehardnessvariationof-and–puretitanium.ppt
- antioxidantactivityoftanninsandrelatedcompoundsfrom.ppt
- briefingsessionon11october2007.ppt
- casestudy-xyz.ppt
- astrocytesandtheirprocesses.someprocessesextendtoward.ppt
- ch01物件導向技術導論(一).ppt
- chapter11respiratorytherapyequipment.ppt
- chapter4theinterplanetaryspace(行星際太空).ppt
- chapter43antifungalandantiviralagents.ppt
原创力文档

文档评论(0)