C++ 名字冲突和继承

来源:互联网 发布:科研大数据平台建设 编辑:程序博客网 时间:2024/05/21 16:21

15.5.2. Name Collisions and Inheritance

Note:A  derived-class member with the same name as a member of the base class hides direct access to the base-class member.

 

Using the Scope Operator to AccessHidden Members

 

We can access a hidden base-class member by using the scope operator:

structDerived : Base {

intget_base_mem() { return Base::mem; }

};

 

Best Practices:When designing a derived class, it is best to avoid name collisions with members of the base class whenever possible.

0 0
原创粉丝点击