菜鸟的博客

纵有疾风起,人生不言弃。

导航

2023年5月23日 #

2023.5.23

摘要: 1 #include <iostream> 2 #include <iomanip> 3 using namespace std; 4 float PI = 3.14159f; 5 class Shape 6 { 7 public: 8 virtual float getArea() = 0; 9 阅读全文

posted @ 2023-05-23 21:24 hhmzd233 阅读(10) 评论(0) 推荐(0)

new的用法复习

摘要: 1 #include <iostream> 2 using namespace std; 3 int* func() 4 { 5 int* p = new int(10); 6 return p; 7 } 8 void test01() 9 { 10 int* p = func(); 11 cout 阅读全文

posted @ 2023-05-23 10:40 hhmzd233 阅读(9) 评论(0) 推荐(0)

2023年5月17日 #

2023.5.16

摘要: 1 相信同学们对复数运算符重载已经相当熟悉啦,那今天那我们来看看分数又该如何处理呢?定义一个分数类FS,有私有成员分子fz,分母fm。另有公有成员函数FS operator + (const FS &f)对运算符“+”进行重载,实现两个分数相加。题目首先给出一个整型数n,紧跟着2n行输入,输入形如3 阅读全文

posted @ 2023-05-17 21:58 hhmzd233 阅读(47) 评论(0) 推荐(0)

2023年5月14日 #

2023.5.14

摘要: 1 #include <iostream> 2 using namespace std; 3 #include <vector> 4 void printVector(vector<int>&v) 5 { 6 for (vector<int>::iterator it = v.begin(); it 阅读全文

posted @ 2023-05-14 23:11 hhmzd233 阅读(14) 评论(0) 推荐(0)

2023.5.13

摘要: 1 #include <iostream> 2 using namespace std; 3 #include <vector> 4 void printVector(vector<int>&v) 5 { 6 for (vector<int>::iterator it = v.begin(); it 阅读全文

posted @ 2023-05-14 17:07 hhmzd233 阅读(12) 评论(0) 推荐(0)

2023年5月13日 #

2023.5.12

摘要: //例6-17 #include <iostream> using namespace std; class Point { public: Point() :x(0), y(0) { cout << "Default Constructor called." << endl; } Point(in 阅读全文

posted @ 2023-05-13 00:24 hhmzd233 阅读(19) 评论(0) 推荐(0)

2023年5月11日 #

2023.5.11

摘要: 1 //例6-16 2 #include <iostream> 3 using namespace std; 4 class Point 5 { 6 public: 7 Point() :x(0), y(0) 8 { 9 cout << "Default Constructor called." < 阅读全文

posted @ 2023-05-11 22:49 hhmzd233 阅读(17) 评论(0) 推荐(0)

2023年5月10日 #

2023.5.10

摘要: 1 [实验任务四]:结构体数据的二进制文件写入 2 【问题描述】 3 定义描述的教师的结构体,依次包含如下属性,工号(int型),姓名(string型),性别(char型),用户输入整数N,描述需要输入教师信息的个数,之后依次输入教师信息,并将教师信息写入工程目录下teacher.dat文件中,以二 阅读全文

posted @ 2023-05-10 19:36 hhmzd233 阅读(31) 评论(0) 推荐(0)

2023年5月9日 #

2023.5.9

摘要: 完成“学生cpp成绩计算”之后,修改Person和Student类,各自增加两个无参构造函数。 仍以Person类为基础,建立一个派生类Teacher,增加以下成员数据: int ID;//教师工号 Student stu[100];//学生数组 int count;//学生数目,最多不超过100 阅读全文

posted @ 2023-05-09 18:42 hhmzd233 阅读(49) 评论(0) 推荐(0)

2023年5月8日 #

2023.5.8

摘要: 1 #include <iostream> 2 using namespace std; 3 #include <fstream> 4 #include <iomanip> 5 void test() 6 { 7 int num; 8 cout << "请输入一个十进制整数:" << endl; 9 阅读全文

posted @ 2023-05-08 19:16 hhmzd233 阅读(15) 评论(0) 推荐(0)