there is a single inheritance of overrides
The base class is overridden in a derived class . print () function.
Derived_overwrite.h#pragma once#include "Base.h" class Derived_overrite:public Base{public: derived_overrite ( int); Virtual ~derived_overrite (void); virtual void print (void) const; Protected: int iderived;};
Derived_overwrite.cpp#include "stdafx.h" #include "derived_overwrite.h" Derived_overrite::D erived_overrite (int i) : Base (0) {iderived = i;cout<< "Derived_overwrite::D erived_overwrite ()" <<ENDL;} Derived_overrite::~derived_overrite (void) {cout<< "Derived_overwrite::~derived_overwrite ()" <<ENDL;} void Derived_overrite::p rint (void) const{cout<< "Derived_overwrite::p rint (), iderived" << iderived < < Endl;}
Base ,derived_overwrite the class diagram is as follows:
rewrite print () the function behaves as follows in the virtual function table:
in order to verify the above C + + object Model, we write the following test code.
C + + object model--a single inheritance with overrides