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;

posted on 2016-07-20 20:15  shoutcharter  阅读(147)  评论(0编辑  收藏  举报

导航