#include using namespace std; class Base { public: Base ( void ); virtual ~Base ( void ); virtual int g ( int a = 0 ); }; Base::Base ( void ) { } Base::~Base ( void ) { } int Base::g ( int a ) { return ( a + 1 ); } class Derived : public virtual Base { public: Derived ( void ); virtual ~Derived ( void ); virtual int g ( int a = 1 ); //违背1 }; Derived::Derived ( void ) { } Derived::~Derived ( void ) { } int Derived::g ( int a ) { return ( a + 11 ); } int main ( void ) { int i; Derived d; Base &b = d; i = b.g ( ); i = d.g ( ); return ( 0 ); }