- 博客(5)
- 收藏
- 关注
原创 上机7 多态 运算符重载 复数乘法
一、实验目的 掌握C++语言多态性的基本概念 掌握运算符重载函数的声明和定义方法 二、实验内容 编写一个程序,实现两个复数的乘法 #include <iostream> using namespace std; class complex { public: double real; double imag; complex(double r = 0, double i = 0) { real = r; imag = i; } }; complex operator*(
2021-12-20 01:35:09
841
原创 上机实验6 继承下的构造函数与析构函数
一、实验目的 1、掌握派生类的声明方法和派生类构造函数的定义方法 2、掌握不同方式下,构造函数与析构函数的执行顺序与构造规则 二、实验内容 1、写出程序运行的结果。 #include<iostream> #include<string> using namespace std; class MyArray { public: MyArray(int length); ~MyArray(); void Input(); void Display(string); p
2021-12-13 00:42:46
798
原创 C++上机 派生类与继承
一、实验目的 1. 掌握派生类的声明方法和派生类构造函数的定义方法。 2. 掌握不同方式下,基类成员在派生类中的访问属性和访问规则。 二、实验内容 #include<iostream> using namespace std; class Base { public: void setx(int i) { x = i; } int getx() { return x; } public: int x; }; class Derived :public Ba
2021-12-11 23:55:49
491
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人