C++学习
文章平均质量分 80
weixin_45421768
这个作者很懒,什么都没留下…
展开
-
C++引用之用法详解
1、引用作为函数的参数 void my_swap1(int a,int b){ int tmp = a; a = b; b=tmp; } void my_swap2(int *a,int *b)//a=&data1,b =data2;{ int tmp = *a; *a = *b; *b = tmp; } void my_swap3(int &a, int &b)//a=data1,b=data2{ int tmp = a; a = b; b= tmp; } void test04(转载 2022-03-29 21:43:08 · 599 阅读 · 0 评论 -
C++文件操作(输入输出、格式控制、文件打开模式、测试流状态、二进制读写)
1.向文件写数据 头文件#include ①Create an instance of ofstream(创建ofstream实例) ②Open the file with open() or ofstreamconstructor (用open()或者构造函数打开文件) ③Writedata to the file with “<<” (用流插入运算符写数据) ④Close the file (explicitly close()) (显式地使用close()函数关闭文件) 若文件已转载 2021-07-20 10:46:36 · 644 阅读 · 2 评论