c++
_faithes
即将毕业的菜鸡选手
(我们不应该只工作更应该去思考人生去追逐)
展开
-
c++文件操作(基于黑马)
文件操作程序运行的数据属于临时数据,一旦结束就释放。所以需要通过文件将数据持久化c++ 文件操作包含头文件文件类型:1.文本文件 :ASCII码存储2.二进制文件操作文件的三大类:1.ofstream 写操作2.ifstream 读操作3.fstream 读写操作写文件文本文件1.包含头文件 #include 2.创建流对象 ofstream ofs;3.打开文件 ofs.open(“文件路径”,打开方式);4.写数据 ofs << “写入的数据原创 2021-07-17 23:41:56 · 267 阅读 · 2 评论 -
c++运算符重载(基于黑马程序员)
1.加号运算符重载运算符重载的俩种方式:全局函数重载和成员函数重载#include <iostream>#include <stdio.h>using namespace std;//运算符重载,也可以发生函数重载class Person {public://1.成员函数重载+号//Person operator+ (Person &p)//{// Person temp;// temp.m_a = m_a + p.m_a;// temp.m_b =原创 2021-07-04 20:01:14 · 221 阅读 · 0 评论 -
c++中友元的三种用法(基于黑马的视频)
全局函数作友元#include<iostream>#include<stdio.h>#include <string>//全局函数作友元访问私有的 using namespace std;class Buliding { friend void GoodGay(Buliding& buliding);public: Buliding() { m_SittingRoom = "客厅"; m_BedRoom = "卧室"; }pub.原创 2021-07-04 17:26:56 · 72 阅读 · 0 评论 -
c++对象模型和this指针(基于黑马程序员的视频)
成员变量和成员函数存储的问题#include <iostream>#include <stdio.h>using namespace std;//在C++中,类内的成员变量和成员函数分开存储//只有非静态成员变量才属于类的对象上 class Person{ int m_a;//只有非静态成员变量才属于类的对象,才会分配空间 static int m_b; void func(){ } static void m_func(){ }};int Person原创 2021-07-04 16:34:04 · 89 阅读 · 0 评论 -
c++类的基本用法(析构和构造函数)
创建长方体类实现求体积和面积的操作,然后分别用类成员函数和全局函数判断俩个长方体是否相等#include <iostream>#include <stdio.h>using namespace std;class Cube {protected: int m_H, m_W, m_L;public: Cube(int h=0,int w=0,int l=0) { m_H = h, m_W = w, m_L = l; } int getH() {原创 2021-07-03 18:50:48 · 162 阅读 · 0 评论