harttle / harttle.github.io

Harttle Land 的源码和文章
https://harttle.land
Creative Commons Attribution 4.0 International
122 stars 32 forks source link

2015/08/25/effective-cpp-27 #132

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

Effective C++ 27:最小化类型转换 | Harttle Land

C++的类型检查只在编译时执行,运行时没有类型错误的概念。理论上讲只要你的代码可以编译那么就运行时就不会有不安全的操作发生。但C++允许类型转换,也正是类型转换破坏了理论上的类型系统。

https://harttle.land/2015/08/25/effective-cpp-27.html

ruixif commented 5 years ago

SpecialWindowvirtual void blink();前面没有必要加virtual吧, base class的virtual function到derived class里还是virtual的。

harttle commented 5 years ago

对,没必要。两者完全等价。加virtual的写法需要敲更多的字,但是更清晰。