博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pure virtual function can has a function body
阅读量:4285 次
发布时间:2019-05-27

本文共 815 字,大约阅读时间需要 2 分钟。

轉載自

 

Your assumption that pure virtual function cannot be called is absolutely incorrect. When a function is declared pure virtual, it simply means that this function cannot get called dynamically, through a virtual dispatch mechanism. Yet, this very same function can easily be called statically, without virtual dispatch.

In C++ language static call to a virtual function is performed when a qualified name of the function is used in the call, i.e. when the function name specified in the call has the <class name>::<function name> form.

For example

struct S {
virtual void foo() = 0; }; void S::foo() { // body for the pure virtual function `S::foo` } struct D : S { void foo() { S::foo(); // static call to `S::foo` from derived class } }; int main() { D d; d.S::foo(); // another static call to `S::foo` }

转载地址:http://oesgi.baihongyu.com/

你可能感兴趣的文章
cordova-plugin-device 获取设备信息整理
查看>>
cordova-plugin-vibration 设备震动整理
查看>>
Cordova事件整理
查看>>
Apache Cordova开发环境搭建(二)VS Code
查看>>
NodeJs的安装和环境变量配置
查看>>
NodeJS命令找不到:'express' 不是内部或外部命令,也不是可运行的程序或批处理文件。
查看>>
Visual Studio Code v1.16发布
查看>>
Node.js自定义实现文件路由功能
查看>>
VS Code中转换大小写功能
查看>>
修改浏览器User-Agent
查看>>
各浏览器的用户代理字符串整理
查看>>
Visual Studio Code v1.17发布
查看>>
EF Linq字符串模糊查询整理
查看>>
Bootstrap 模态框垂直居中处理
查看>>
Visual Studio Code v1.18发布
查看>>
Ionic2 相关文档整理
查看>>
Angular CLI简介
查看>>
Angular CLI简介2
查看>>
Angular2开发环境搭建之VS Code
查看>>
Angular 安全导航操作符(?.)和空属性路径
查看>>