摘要: 编写程序实现如下功能:打开指定的一个文本文件,在每一行前加行号后将其输出到另一个文本文件中。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 4 #include <fstream> 5 using namespace s 阅读全文
posted @ 2023-03-28 20:28 nlkdfgnvfdkl 阅读(67) 评论(0) 推荐(0)
摘要: 提示用户输入一个十进制整数,分别用十进制、八进制和十六进制形式输出。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 4 #include <fstream> 5 using namespace std; 6 7 int 阅读全文
posted @ 2023-03-28 19:50 nlkdfgnvfdkl 阅读(49) 评论(0) 推荐(0)
摘要: 定义一个dog类,包含体重和年龄两个成员变量及相应的成员函数,声明一个实例dog1,体重为5,年龄为10,使用I/O流把dog1的状态写入磁盘文件,再声明另一个实例dog2,通过读文件把dog1的状态赋给dog2。分别使用文本方式和二进制方式操作文件,看看结果有何不同;再看看磁盘文件的ASCII码有 阅读全文
posted @ 2023-03-28 19:39 nlkdfgnvfdkl 阅读(56) 评论(0) 推荐(0)
摘要: 使用I/O流以文本方式打开上题建立的文件test1.txt,在次此文件后面添加字符“已成功添加字符!”,然后读出整个文件的内容显示出来,看看是否正确。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 4 #include 阅读全文
posted @ 2023-03-28 19:00 nlkdfgnvfdkl 阅读(44) 评论(0) 推荐(0)
摘要: 使用I/O流以文本方式打开上一题建立的文件test1.txt,读出其内容显示出来,看看是否正确。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 4 #include <fstream> 5 using namespace 阅读全文
posted @ 2023-03-27 22:27 nlkdfgnvfdkl 阅读(39) 评论(0) 推荐(0)
摘要: 使用I/O流以文本方式建立一个文件test1.txt,写入字符“已成功写入文件!”,用其它字处理程序(例如windows的记事本程序Notepad)打开,看看是否正确写入。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 阅读全文
posted @ 2023-03-27 22:20 nlkdfgnvfdkl 阅读(50) 评论(0) 推荐(0)
摘要: 编写程序定义类Point,有数据成员x,y.为其定义友元函数实现重载“+”。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 4 #include <stdio.h> 5 using namespace std; 6 7 阅读全文
posted @ 2023-03-18 23:30 nlkdfgnvfdkl 阅读(50) 评论(0) 推荐(0)
摘要: 对类Point重载“++”(自增)、“--”(自减)运算符,要求同时重载前缀和后缀的形式。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 4 #include <stdio.h> 5 using namespace st 阅读全文
posted @ 2023-03-17 23:01 nlkdfgnvfdkl 阅读(112) 评论(0) 推荐(0)
摘要: 请编写-一个计数器Counter类,对其重载运算符“十”。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 4 #include <stdio.h> 5 using namespace std; 6 7 class Cou 阅读全文
posted @ 2023-03-17 22:03 nlkdfgnvfdkl 阅读(65) 评论(0) 推荐(0)
摘要: 定义一个基类Shape,在此基础上派生出Rectangle和Circle,二者都有getArea()函数计算对象的面积。使用Rectangle类创建一个派生类Square。 1 #include <iostream> 2 #include <string> 3 #include<string.h> 阅读全文
posted @ 2023-03-16 22:48 nlkdfgnvfdkl 阅读(38) 评论(0) 推荐(0)