ImageVerifierCode 换一换
格式:DOCX , 页数:18 ,大小:16.77KB ,
资源ID:22585977      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/22585977.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C++面向对象程序设计实验报告文档格式.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C++面向对象程序设计实验报告文档格式.docx

1、 void print();【circle.cpp】#includecircle.hcircle:circle(float x,float y):pi(3.14) r=x; h=y;void circle:print() cout底面积为:r*r*piendl;体积为:r*r*pi*h#ifndef distance_h#define distance_hnamespace meclass distancepoint p1;point p2; distance(int x1,int x2,int y1,int y2);【distance.cpp】distance.hme:distance:di

2、stance(int x1,int x2,int y1,int y2):p1(x1,y1),p2(x2,y2)cout”两点间的距离为:”sqrt(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); me:distance s(1,2,1,2);两点间的距离为:1.41实验四定义学生类(姓名,学号),生日类(年,月,日),利用友元类,输出某个学生的姓名,学号,及其生日。【student.h】birthday.hclass student char *name; int ID; student(char *s,int n); void print(birthday &a);【birt

3、hday.h】#ifndef bi#define biclass birthday int year,mouth,day; friend class student; birthday(int x,int y,int z);【student.cpp】student.hstudent:student(char *s,int n)ID=n;name=new charstrlen(s)+1;strcpy(name,s);void student:print(birthday &b)姓名:name学号:ID生日:b.yearb.mouthb.daybirthday:birthday(int x,int

4、 y,int z)year=x; mouth=y;day=z;iostream void main() student a(tjl,117); birthday b(1990,9,1); a.print(b);tjl117199091实验五 student(name,id,total),total为静态成员,在student中设置静态函数来处理total。在main()函数中显示name,id,totalchar *name;int id;static int total; student(char *na,int id1); void print(); static void print1(

5、);【total.cpp】string.hint student:total=0;student(char *na,int id1) id=id1;name=new charstrlen(na)+1;strcpy(name,na);+total;print1()total;name:coutid:idstudent a(tang,61);student b(guo,45);a.print();b.print();print1();tang61guo45实验六基类-学生类(姓名,学号),子类-大学生类(专业),继承方式:公有继承,在主函数中显示某个大学生的信息。#ifndef _st1#defi

6、ne _st1 int id; student();student()delete name;id=id1;【cstudent.h】#ifndef _cst#define _cstclass cstudent:public student char *project; cstudent(); cstudent(char *na,int id1,char *pro); void print1();【cstudent.cpp】cstudent.hcstudent:cstudent()delete project;cstudent(char *na,int id1,char *pro):studen

7、t(na,id1)project=new charstrlen(pro)+1;strcpy(project,pro);void cstudent:student:print();project:projectmain()cstudent a(,17,computer);a.print1();17conputer实验七基类shape,派生类circle(半径R),tangcle(长a,宽b),它们都有求面积的函数area(),利用虚函数求两个派生类对象的面积【shape.h】#ifndef _shape#define _shapeclass shapevirtual void area();【s

8、hape.cpp】shape.hvoid shape:area()class circle:public shapefloat r;const float pi;circle(float r1);void area(); ;circle(float r1):r=r1;pi*r*r【tangcle.h】class tangcle:float a,b;tangcle(float c,float d);【tangcle.cpp】tangcle.htangcle:tangcle(float c, float d)a=c;b=d;void tangcle:a*barea();b;12.5612实验八重载

9、减法运算符,使得两个复数可以相减【complex.h】iostream.h#ifndef _COMPLEX_H#define _COMPLEX_Hclass complex double a; double b; complex(double a,double b); friend void operator -(complex x,complex y);【complex.cpp】complex.hcomplex:complex(double a1,double b1)a=a1;b=b1;void operator-(complex x,complex y)实部是:x.a-y.a虚部是:x.b-y.bcomplex A1(1.0,2.0),A2(3.0,4.0);A1-A2; -2虚部:-2实验九将文件text1的内容拷贝到文件text2中#include int main() ifstream in(H:text1.txt if(!in) cerrread text1 error exit(1); ofstream out(text2.txtout)write text2 error char ch; while(in) in.get(ch); out.put(ch); return 0;实验结果:text1:55555;复制到text2显示55555文件中复制成功

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1