摘要:1 #include <iostream> 2 #include<iomanip> 3 using namespace std; 4 class Horse 5 { 6 public: 7 Horse() 8 { 9 cout << "Horse 申请了空间..." << endl; 10 } 11
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:1 相信同学们对复数运算符重载已经相当熟悉啦,那今天那我们来看看分数又该如何处理呢?定义一个分数类FS,有私有成员分子fz,分母fm。另有公有成员函数FS operator + (const FS &f)对运算符“+”进行重载,实现两个分数相加。题目首先给出一个整型数n,紧跟着2n行输入,输入形如3
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要://例6-17 #include <iostream> using namespace std; class Point { public: Point() :x(0), y(0) { cout << "Default Constructor called." << endl; } Point(in
阅读全文
摘要: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." <
阅读全文
摘要:1 [实验任务四]:结构体数据的二进制文件写入 2 【问题描述】 3 定义描述的教师的结构体,依次包含如下属性,工号(int型),姓名(string型),性别(char型),用户输入整数N,描述需要输入教师信息的个数,之后依次输入教师信息,并将教师信息写入工程目录下teacher.dat文件中,以二
阅读全文
摘要:完成“学生cpp成绩计算”之后,修改Person和Student类,各自增加两个无参构造函数。 仍以Person类为基础,建立一个派生类Teacher,增加以下成员数据: int ID;//教师工号 Student stu[100];//学生数组 int count;//学生数目,最多不超过100
阅读全文
摘要:1 #include <iostream> 2 using namespace std; 3 #include <fstream> 4 #include <iomanip> 5 void test() 6 { 7 int num; 8 cout << "请输入一个十进制整数:" << endl; 9
阅读全文
摘要:1 //boss.h 2 #pragma once 3 #include <iostream> 4 using namespace std; 5 #include "worker.h" 6 class Boss :public Worker 7 { 8 public: 9 //构造函数 10 Bos
阅读全文
摘要:1 //11-6 2 #include <iostream> 3 #include <fstream> 4 #include <string> 5 using namespace std; 6 class Dog 7 { 8 public: 9 Dog(){} 10 Dog(int age,int
阅读全文
摘要:1 //11-3 2 #include <iostream> 3 #include <fstream> 4 using namespace std; 5 void test01() 6 { 7 ofstream ofs; 8 ofs.open("test1.txt",ios::out); 9 ofs
阅读全文
摘要:1 //new在堆区开辟数据,手动开辟,手动释放 2 #include <iostream> 3 using namespace std; 4 //1.new的基本语法 5 int* func() 6 { 7 //new返回的是指针 8 int* p = new int(10); 9 return
阅读全文
摘要:1 //#include <iostream> 2 //using namespace std; 3 //#include <fstream> 4 ////写文本文件 5 //void test01() 6 //{ 7 // //1.包含头文件 fstream 8 // //2.创建流对象 9 //
阅读全文
摘要:1 //1.2.3函数模板案例 2 //利用函数模板封装一个排序的函数,可以对不同数据类型数组进行排序。 3 //排序规则从大到小,排序算法为选择排序 4 //分别利用char数组和int数组进行测试 5 #include <iostream> 6 using namespace std; 7 te
阅读全文