![](https://img-blog.csdnimg.cn/6633958b99924c678cd894462a1e1b9e.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
c++零落知识点(不更新了)
各种小技巧,小知识点
踏遍三十六岸
万般皆是命 半点不由人……
展开
-
读二进制文件(C++)
#include <iostream>using namespace std;#include<fstream> class Person{ public: char name[64];};int main(int argc, char** argv) { ifstream ofs; ofs.open("C:\\项目\\devc++\\person.txt",ios::in | ios::binary); if(!ofs.is_open()) { co.原创 2022-05-17 19:23:42 · 169 阅读 · 0 评论 -
二进制写文件(c++)
#include <iostream>using namespace std; #include<fstream>class Person{ public: char name[10]; int age;};int main(int argc, char** argv) { ofstream ofs; Person p={"张三",23}; ofs.open("Person.txt",ios::out|ios::binary); ofs.write(.原创 2022-05-16 09:15:23 · 157 阅读 · 0 评论 -
读文件(c++)
#include <iostream>#include<fstream>#include<string> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { ifstream ifs; ifs.o.原创 2022-05-15 22:29:33 · 83 阅读 · 0 评论 -
写文件(c++)
写文件#include <iostream>#include<fstream>using namespace std;int main(int argc, char** argv) { ofstream ofs; ofs.open("test.txt",ios::out); ofs<<"姓名:ty"<<endl; ofs<<"姓别:man"<<endl; ofs.close(); return ...原创 2022-05-15 22:00:34 · 947 阅读 · 0 评论 -
多态(纯虚函数)c++
#include <iostream>using namespace std; class Base{ public: //抽象类 //特点:1.不能实例化对象 Base b; new Base; //2.抽象函数子类必须重写抽象类中纯虚函数 virtual void fun()=0;//纯虚函数 };class Son:public Base{ public: virtual void fun(){ cout<<"fun 调用".原创 2022-05-14 19:18:29 · 133 阅读 · 0 评论 -
赋值重载(c++)
知识点:负值重载 深拷贝 this指针#include <iostream>using namespace std;class Person{public: Person(int age) { m_age=new int(age); } ~Person() { if(m_age!=NULL) { delete m_age; m_age=N...原创 2022-04-28 21:22:24 · 742 阅读 · 0 评论 -
类所占内存
#include <iostream>using namespace std;//成员函数 成员变量分开储存class Person{};class Circle{ int r;//非静态成员变量 属于类的对象};class Line{ int a;//非静态成员变量 属于类的对象 static int b;//静态成员变量 不属于类的对象上};int Line::b=0;int main(){ Person p; ...原创 2022-04-24 20:34:07 · 353 阅读 · 0 评论 -
new开辟数组
new在堆区开辟空间#include <iostream>using namespace std;const int Max=10;void a(){ int *arr=new int[Max]; for(int i=0; i<Max; i++) { arr[i]=i+100; } for(int i=0; i<Max; i++) { cout<<"打印 ...原创 2022-04-20 19:19:41 · 238 阅读 · 0 评论 -
日期 计算器(代码打开)
放松一下日期小技巧#include <stdio.h>#include <stdlib.h>int main(){ system("date/T"); return 0;}计算器小技巧#include <stdio.h>#include <stdlib.h>int main(){ system("calc.exe"); return 0;}...原创 2022-03-30 13:48:16 · 180 阅读 · 0 评论 -
关机小程序
点个赞代码如下:#include <stdio.h>#include <stdlib.h>#include <windows.h>int main(){ system("shotdown -s -t 5 -f"); return 0;}白~~~原创 2022-03-28 18:18:41 · 275 阅读 · 0 评论