首页 > 技术文章 > overload and overwrite in C++

gaoxianzhi 2016-07-20 20:15 原文

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;

推荐阅读