自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(5)
  • 收藏
  • 关注

原创 实验八:运算符重载

一: 二:运算符重载: 多态性: 在面向对象方法中,所谓多态性就是不同对象收到相同的消息时,产生不同的行为。在C++ 程序设计中,多态性是指用一个名字定义不同的函数,这些函数执行不同但又类似的操作,这样就可以用同一个函数名调用不同内容的函数。 运算符重载: 运算符重载规则如下: ①、 C++中的运算符除了少数几个之外,全部可以重载,而且只能重载C++中已有的运算符。 ②、 重载之后运算符的优先级和结合性都不会改变。 ③、 运算符重载是针对新类型数据的实际需要,对原有运算符进行适当的改造。一般来说,

2021-12-18 10:44:50 612 1

原创 实验七:继承下的构造函数与析构函数

一.实验目的: 二.实验内容: #include "twj.h" using namespace std; class MyArray { public: MyArray(int length); ~MyArray(); void Input(); void Display(string); protected: int* alist; int length; }; MyArray::MyArray(int leng) { if (leng <= 0) { cou.

2021-12-11 19:46:41 445

原创 实验六:派生类与继承

一. 实验目的: 二.实验内容: 输入以下代码,观察结果: #include "twj.h" using namespace std; class Base { public: void setx(int i) { x = i; } int getx() { return x; } public: int x; }; class Derived :public Base { public: void sety(int i) { y = i; } i...

2021-12-11 19:25:59 510

原创 上机实验五

一:实验目的 二:实验过程 内容(A) 1.使用对象作为函数参数 #include"twj.h" using namespace std; class Tr { public: Tr(int n) { i = n; } void set_i(int n) { i = n; } int get_i() { return i; } private: int i; }; void sqr_it(Tr ob) { ob.set_i(ob.get_i() * ob.get.

2021-11-28 15:11:40 221 2

原创 上机实验三:构造函数和构析函数

1.实验任务: 2.实验过程及代码: #include "twj.h" using namespace std; class Score { private: int num; int moren;// string name[100]; float fenshu[100][4]; float avg_stu[100]; float avg_xueke[4]; public: Score(); ~Score(); void...

2021-11-20 11:55:31 273

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除