博客
关于我
继承关系作用下的虚函数手工调用
阅读量:491 次
发布时间:2019-03-07

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

#include
#include
using namespace std;class A{ public: virtual void x() { cout<<"x()"<

在这里插入图片描述

说明:虚函数表里的指针,这里是有一些指向了子类中的虚函数(y函数覆盖导致),,如果光光是new一个父类,当然,这个虚函数表里存放的指针当然都是指向本类中的虚函数的。

在这里插入图片描述

此列中的子类对象和父类对象内存空间布局如下:
在这里插入图片描述

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

你可能感兴趣的文章
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>