摘要:所谓函数模板,实际上是建立一个通用函数,其函数类型和形参类型不具体指定,用一个虚拟的类型来代表。这个通用函数就称为函数模板。凡是函数体相同的函数都可以用这个模板来代替,不必定义多个函数,只需在模板中定义一次即可。在调用函数时系统会根据实参的类型来取代模板中的虚拟类型,从而实现了不同函数的功能。 函数
阅读全文
摘要:Immortal.h #pragma once #include <string> #include <vector> #include "SpriteStone.h" #include "Monster.h" #include <iostream> using namespace std; typ
阅读全文
摘要:从练习2中的num.txt文件读取各个整数, 打印出最大值和最小值, 以及平均值,和. #include <iostream> #include <Windows.h> #include <fstream> using namespace std; int main(void) { ifstream
阅读全文
摘要:输入任意多个整数, 把这些数据保存到文件data.txt中. 如果在输入的过程中, 输入错误, 则提示用户重新输入. 指导用户输入结束(按ctrl + z) [每行最多保存10个整数] cin.ignore(count, c); 从输入流中提取并丢弃字符,直到遇到下列三种情况 1.提取的字符达到了参
阅读全文
摘要:boy.h: #pragma once #include <string> #include <vector> #include "Single.h" using namespace std; class Girl; class Boy : public Single { public: Boy()
阅读全文
摘要:#include <stdio.h> #include <Windows.h> void init(char *data, int len) { unsigned int n = len * 8; char* p = NULL; for (unsigned int i = 0; i < n; i++
阅读全文
摘要:按照指定格式读取文件 #include <iostream> #include <string> #include <fstream> #include <Windows.h> using namespace std; int main(void) { ifstream inFile; string
阅读全文
摘要:题目:定义一个或多个类,来描述以下需求: 汽车,有多个轮胎,一个发动机,品牌,型号,价格,行驶里程。 轮胎,有品牌,尺寸,气压。 发动机,有品牌,型号。 Car.h #pragma once #include "Tire.h" #include "Engine.h" #include <sstrea
阅读全文