当前位置: 首页 > 其他范文 > 其他范文

c,,实验三

作者:北极星的眼泪 | 发布时间:2020-12-26 00:53:24 收藏本文 下载本文

桂林电子科技大学 数学与计算科学学院实验报告 实验室:

实验日期:

年 月 日 院(系)数学与计算科学学院学号 120071013 姓名 杰森 成绩 课程 名称 C++程序设计 实验项目 名 称 类和对象(二)一,实验目的(1)进一步加深对类和对象的理解。

(2)掌握类的构造函数和析构函数的概念和使用方法。

(3)掌握对象数组、对象的指针及其使用方法。

(4)掌握友元的概念和使用。

(5)了解类模板的使用方法。

二,实验所用到的相关知识点 会运用友元函数,学会巧妙运用声明类的方法,类和类的成员的概念以及定义对象的方法,懂得找出程序的错误以及学会调试基于对象的程序 三,实验过程原始记录(数据,图表,计算等)3 3—1 1 # include using namespace std;class Student { public: Student(int n, float s): num(n), score(s){ } void change(int n , float s){ num=n;score=s;} void display(){cout<< num <<" "<

{ Student stud(101, 78.5);stud.display();stud.change(101, 80.5);stud.display();return 0;} void fun(Student &stu){stu.display();stu.change(101,80.5);stu.display();} } 3—3 #include using namespace std;class Date;class Time {public: Time(int, int, int);friend void display(const Date&,const Time &);private: int hour;int minute;int sec;};Time::Time(int h,int m,int s){ hour=h;minute=m;

sec=s;} class Date {public: Date(int, int, int);friend void display(const Date &,const Time &);private: int month;int day;int year;};Date::Date(int m, int d, int y){ month=m;day=d;year=y;} void display(const Date &d,const Time &t){cout<

3—4 #include using namespace std;template class Compare { public: Compare(A a,A b){x=a;y=b;} A max(){return(x>y)?x:y;} A min(){return(x cmp1(3,7);cout< cmp2(45.78,93.6);cout< cmp3("a","A");cout<

五,实验结果分析或总结 花了一早上的时间完成三四次试验,经过本次实验,了解了类和对象的基本编程,基本掌握声明类的方法,类和类的成员的概念以及定义对象的方法。能初步掌握用类和对象编制基于对象的程序。不过过程中还是很容易出现一些比较常见的小问题,单词经常拼写错误。

C,,实验五

C,,实验二

C实验六范文

c语言实验心得体会

C(II)实验六

本文标题: c,,实验三
链接地址:https://www.dawendou.com/fanwen/qitafanwen/337473.html

版权声明:
1.大文斗范文网的资料来自互联网以及用户的投稿,用于非商业性学习目的免费阅览。
2.《c,,实验三》一文的著作权归原作者所有,仅供学习参考,转载或引用时请保留版权信息。
3.如果本网所转载内容不慎侵犯了您的权益,请联系我们,我们将会及时删除。

重点推荐栏目

关于大文斗范文网 | 在线投稿 | 网站声明 | 联系我们 | 网站帮助 | 投诉与建议 | 人才招聘 | 网站大事记
Copyright © 2004-2025 dawendou.com Inc. All Rights Reserved.大文斗范文网 版权所有