作者:RaymondHuang

Linux的目录结构

Linux文件组织方式 Linux的目录结构是一个树形结构。 众所周知,Windows可以拥有多个盘符(多棵树),文件的组织方式类似下方: 但是Linux中

RaymondHuang 发布于 2023-07-22

计算机基础

《鸟哥Linux私房菜》笔记

RaymondHuang 发布于 2023-07-16
C++

文件的读写(IO流)

在C++中如果想要读写文件,需要引入一个库fstream,代表的是file stream,文件流的意思: #include <fstream> 接下来定义一个简单的写文件的函数: void write_file() {     ofstream ofs; // ofstream代表的是out fil

RaymondHuang 发布于 2022-12-18
C++

处理异常

有时候我们需要手动处理一些能预料到的错误,来保证程序不会崩溃: void main() {     try {         string s = "bye";         cout << s.at(4);         //cout << s[4];     }     catch (ou

RaymondHuang 发布于 2022-12-18
C++

类的多态(Polymorphism)

多态的概念: 首先,我们先来看一个静态的多态的例子: class Point { public:     int x;     int y;     Point() : x(0), y(0) {}     Point(int _x, int _y) : x(_x), y(_y) {}  &nb

RaymondHuang 发布于 2022-12-18
C++

类中的运算符重载

普通运算符重载: 通过运算符重载,可以定义对象执行相应运算符之后的行为,比如定义两个对象相加的行为: class Person { public:     int age;     Person() : age(18) {}     Person operator+(const Person& 

RaymondHuang 发布于 2022-12-18
C++

类的继承(Inheritance)

类的继承: 通过继承来减少代码量与提高复用性,一个基本例子: class Father { public:     int age;     string name;          Father(): age(30),name("Father") {} } class Son: public 

RaymondHuang 发布于 2022-12-17
C++

类的友元(friend)

这个东西不太重要,有个印象就行。 首先需要明确的是,在类中声明成员或方法的时候,如果没写访问权限,那就默认是private的: class Student {     int age; // private的成员 public:     int id; // public的成员 } 使用friend

RaymondHuang 发布于 2022-12-17
C++

类中的静态变量与静态方法

静态变量,指的是一个类中被static修饰的变量,这个变量可以被类中的方法、对象、类名直接修改或访问: class Student { public:     char color;     static int n_eyes;     Student() : color('b') {} };

RaymondHuang 发布于 2022-12-17
C++

类中的this指针

在构造函数中,如果传进来的形参名字和成员名字一样,需要用this指针区分,否则无法赋值: class Student { public:     int id;          Student(int id) {         this->id = id; // 如果直接写成id = id,那么

RaymondHuang 发布于 2022-12-17