您的位置:首页 > 编程语言 > C语言/C++

overload and overwrite in C++

2016-07-20 20:15 441 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: