Skip to content

Commit

Permalink
Merge pull request huihut#75 from ijpq/master
Browse files Browse the repository at this point in the history
关于动态绑定的补充
  • Loading branch information
huihut authored Mar 18, 2021
2 parents ac18079 + afdbe1d commit f279fe8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,12 @@ public:
```

#### 动态多态(运行期期/晚绑定)

* 虚函数:用 virtual 修饰成员函数,使其成为虚函数
* 动态绑定:当使用基类的引用或指针调用一个虚函数时将发生动态绑定

**注意:**

* 可以将派生类的对象赋值给基类的指针或引用,反之不可
* 普通函数(非类成员函数)不能是虚函数
* 静态函数(static)不能是虚函数
* 构造函数不能是虚函数(因为在调用构造函数时,虚表指针并没有在对象的内存空间中,必须要构造函数调用完成后才会形成虚表指针)
Expand Down

0 comments on commit f279fe8

Please sign in to comment.