摘要: 学生类的析构与构造 #include <iostream>#include <string.h>using namespace std; class Student{public: Student(int _num,string _name,char _sex) { num=_num; name=_ 阅读全文
posted @ 2023-05-10 17:27 涨涨涨张 阅读(17) 评论(0) 推荐(0)
摘要: 派生类练习 #include <iostream>#include <string>using namespace std; class Animal{ public: Animal() {} void set_weight(int w) { m_nWeightBase=w; } int get_w 阅读全文
posted @ 2023-05-09 18:26 涨涨涨张 阅读(21) 评论(0) 推荐(0)
摘要: 派生类 #include <iostream> #include <string> using namespace std; class Animal { public: Animal() {} void set_weight(int w) { m_nWeightBase=w; } int get_ 阅读全文
posted @ 2023-05-08 19:08 涨涨涨张 阅读(11) 评论(0) 推荐(0)
摘要: 动物世界 1、实现Mammal类的方法 2、由Mammal类派生出Dog类,在Dog类中增加itsColor成员(COLOR类型) 3、Dog类中增加以下方法: constructors: Dog()、Dog(int age)、Dog(int age, int weight)、Dog(int age 阅读全文
posted @ 2023-05-05 19:19 涨涨涨张 阅读(118) 评论(0) 推荐(0)
摘要: 派生类的定义和使用 #include <iostream>#include <string>using namespace std; class Animal{ public: Animal() {} void speak() { cout<<"animal language!"; }};class 阅读全文
posted @ 2023-05-04 20:30 涨涨涨张 阅读(21) 评论(0) 推荐(0)
摘要: 狗的继承 完成两个类,一个类Animal,表示动物类,有一个成员表示年龄。一个类Dog,继承自Animal,有一个新的数据成员表示颜色,合理设计这两个类,使得测试程序可以运行并得到正确的结果。 #include <iostream>using namespace std; class Animal{ 阅读全文
posted @ 2023-04-27 18:36 涨涨涨张 阅读(105) 评论(0) 推荐(0)
摘要: 一个捐款人类Donator及一个相关函数getMaxName( ),Donator类中包含捐款人的姓名及其捐款额。输出一批捐款人来到前后的捐款总金额,以及本批次捐款人中捐款最高者的姓名。 #include <iostream>using namespace std; class Donator{ p 阅读全文
posted @ 2023-04-26 21:21 涨涨涨张 阅读(26) 评论(0) 推荐(0)
摘要: 计算年龄问题 定义一个Birthday类,其成员变量有3个整形变量(出生的年月日):year,month,day;提供构造方法对这3个成员变量进行初始化;成员函数有getAge(),其功能是实现计算到2017年12月25日时该Birthday对象的年龄。 #include<iostream>usin 阅读全文
posted @ 2023-04-25 19:46 涨涨涨张 阅读(14) 评论(0) 推荐(0)
摘要: 立方体类Box的实现,完成计算体积、计算表面积、输出结果等功能。 #include<iostream>using namespace std; class Box {public: void seta(float a) { len=a; } float getvolume() { return le 阅读全文
posted @ 2023-04-24 10:43 涨涨涨张 阅读(19) 评论(0) 推荐(0)
摘要: 判断是否为闰年 定义一个日期类Date,内有数据成员year、month和day,分别代表年、月、日,并若干有成员函数:构造函数用于初始化数据成员,isLeap函数用于闰年的判断。编写主函数:创建日期对象,判断该年是否是闰年。 #include<iostream>using namespace st 阅读全文
posted @ 2023-04-21 18:33 涨涨涨张 阅读(51) 评论(0) 推荐(0)