1. overload :
don‘t using it in different scope. it will hidden the one in base or global scope.
2. overwrite:
using it in different scope. add virtual in base scope. and only be effective for point and reference. will not work for object.
base.f();
derive.f();
base * bs=new derive();
bs->f() //base one without virtual;
bs->f() //derive one with virtual;
时间: 2024-10-27 03:25:50