#include
class Base{
public : Base(){}
Base(bool arg){foo();}
virtual void foo(int i=42){cout<<"base "<<i<<endl;}
};
class Derived:public Base
{
public:Derived(){};
Derived(bool arg):Base(arg){foo();}
virtual void foo(int i=12){cout<<"Derived "<<i<<endl;}
};
//结果1:
//Derived 42
//Base 42 ????
int main(){
Derived d;
Base &b1=d;
//Base b2=d;
b1.foo();
//b2.foo();
return 0;
}
//结果2:
//Base 42
//Derived 12
int test(){
Base* b = new Derived(true);
delete b;
return 0;
}