vtable.cpp

来自「压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架&gt」· C++ 代码 · 共 45 行

CPP
45
字号
#include <QString>#include <qstd.h>using namespace qstd;#include "vtable.h"Base::Base() {    m_X = 4;    m_Y = 12;    cout << " Base::Base: " ;    virtualFun();}Derived::Derived() {    m_X = 5;    m_Y = 13;    m_Z = 22;}void Base::virtualFun() const {    QString val=QString("[%1,%2]").arg(m_X).arg(m_Y);    cout << " VF: the opposite of Acid: " << val << endl;}void Derived::virtualFun() const {    QString val=QString("[%1,%2,%3)")        .arg(m_X).arg(m_Y).arg(m_Z);    cout << " VF: add some treble: " << val << endl;}Base::~Base() {    cout << " ~Base() " << endl;    virtualFun();}Derived::~Derived() {    cout << " ~Derived() " << endl;}int main() {    Base b;    Derived d;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?