- 博客(6)
- 收藏
- 关注
原创 Lesson4
模板类型推导 模板函数可以根据函数参数的类型推导出模板参数的类型,原理和自动类型(auto)推导是一样的。输入是左值的情况: template <typename T> void func1(T x) {} template <typename T> void func2(T& x) {} template <typename T> void func3(T&& x) {} int main() { int x = 1024; fu
2022-01-20 19:26:39
417
原创 Lesson3
New 和 delete 关键字 new(new operator)做了两件事情: 调用 operator new() 函数为对象分配内存; 调用 placement new() 函数在分配的内存上构造对象(调用对象的构造函数)。 关键字 delete(delete operator)做了两件事情: 调用对象的析构函数; 调用 operator delete() 函数释放对象占用的内存。 class A { public: A() = default; ~A() = default; };
2022-01-18 21:20:01
321
原创 Lesson2
接口 回顾一下 Human 和 Student: class Human { // 虚基类 public: virtual ~Human() {}; // 不能是纯虚函数 virtual void talk() = 0; // 纯虚函数,没有函数体 }; class Student final : public Human { public: Student(const std::string& name) : name_(name) {} void talk() override {
2022-01-16 21:37:19
203
原创 Lesson1
继承 现在需要建立 Student 类型和 Teacher 类型。我们发现,两者有相同的地方,比如都有名字,都可以说话。两者也有不同的地方,比如说话的方式不同。我们可以将相同的地方抽象成 Human 类型,让 Student 和 Teacher 去继承 Human,再让两者分别在自己的类型中实现不同的地方。这里,Human 是基类,Student 和 Teacher 是子类: class Human { public: virtual ~Human() {}; virtual void talk()
2022-01-14 01:27:25
123
原创 Ubuntu 安装 esys-Escript
目录安装 Anaconda安装 esys-Escript 安装 Anaconda 从 官网 下载 Linux 版本的 Anaconda。 在 Ubuntu 中打开终端,进入下载目录: cd ~/Downloads 查看安装文件: ls 安装: bash Anaconda-latest-Linux-x86_64.sh 安装 esys-Escript 进入安装目录: cd ~/anaconda3 创建新环境: conda create --name esys-Escript 进入新环境: conda
2020-09-29 20:53:45
563
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人