Raymond's Blog 睿蒙博客

归档

2023 年 07 月

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

2023-07-16

《鸟哥Linux私房菜》笔记

2022 年 12 月

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

2022-12-18

C++
有时候我们需要手动处理一些能预料到的错误,来保证程序不会崩溃: void main() {     try {         string s = "bye";         cout << s.at(4);         //cout << s[4];     }     catch (ou
C++
多态的概念: 首先,我们先来看一个静态的多态的例子: class Point { public:     int x;     int y;     Point() : x(0), y(0) {}     Point(int _x, int _y) : x(_x), y(_y) {}  &nb
C++
普通运算符重载: 通过运算符重载,可以定义对象执行相应运算符之后的行为,比如定义两个对象相加的行为: class Person { public:     int age;     Person() : age(18) {}     Person operator+(const Person& 
C++
类的继承: 通过继承来减少代码量与提高复用性,一个基本例子: class Father { public:     int age;     string name;          Father(): age(30),name("Father") {} } class Son: public 
C++
这个东西不太重要,有个印象就行。 首先需要明确的是,在类中声明成员或方法的时候,如果没写访问权限,那就默认是private的: class Student {     int age; // private的成员 public:     int id; // public的成员 } 使用friend
C++
静态变量,指的是一个类中被static修饰的变量,这个变量可以被类中的方法、对象、类名直接修改或访问: class Student { public:     char color;     static int n_eyes;     Student() : color('b') {} };

2022-12-17

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