本文共 480 字,大约阅读时间需要 1 分钟。
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.
转载地址:http://ayyii.baihongyu.com/