overload and overwrite in C++

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;

原文地址:https://www.cnblogs.com/gaoxianzhi/p/5689581.html