摘要: #include <iostream> #include <fstream>//包含头文件 #include <string> using namespace std; //文本文件,读文件 void test01() { //1.包含头文件 //2.创建流对象 ifstream ifs; //3. 阅读全文
posted @ 2021-09-05 23:12 梦之心 阅读(36) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <fstream>//包含头文件 using namespace std; void test01() { //1.包含头文件 //2.创建流对象 ofstream ofs; //3.打开文件 ofs.open("text.txt", ios 阅读全文
posted @ 2021-09-05 23:12 梦之心 阅读(34) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <fstream>//包含头文件 using namespace std; //二进制文件 写文件 class Person { public: char m_name[64];//姓名 int m_age;//年龄 }; void test 阅读全文
posted @ 2021-09-05 23:11 梦之心 阅读(110) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <fstream>//包含头文件 #include <string> using namespace std; //二进制文件 读文件 class Person { public: char m_name[64];//姓名 int m_age 阅读全文
posted @ 2021-09-05 23:10 梦之心 阅读(147) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; //引用做函数的返回值 //1.不要返回局部变量的引用 int& test01() { int a = 10; //局部变量存在四区中的栈区 return a; } //2.函数的调用可以作为左值 int& test0 阅读全文
posted @ 2021-09-05 21:55 梦之心 阅读(55) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; //交换函数 //1.值传递 void swap01(int a, int b) { int temp = a; a = b; b = temp; cout << "swap01 a=" << a << endl; c 阅读全文
posted @ 2021-09-05 21:40 梦之心 阅读(35) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; int main() { int a = 10; //1.引用必须初始化 //int& b;//错误,必须初始化 int& b = a; //2.引用初始化后,不可以更改 int c = 20; b = c;//赋值操 阅读全文
posted @ 2021-09-05 21:24 梦之心 阅读(47) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; int main() { //引用基本语法 //数据类型 &别名=原名 int a = 10; //创建引用 int& b = a; cout << "a=" << a << endl; cout << "b=" << 阅读全文
posted @ 2021-09-05 21:13 梦之心 阅读(34) 评论(0) 推荐(0) 编辑