c++ using declaration, scope and access control

后端 未结 3 1454
深忆病人
深忆病人 2020-12-09 19:55

Typically the \'using\' declaration is used to bring into scope some member functions of base classes that would otherwise be hidden. From that point of view it is only a me

3条回答
  •  清歌不尽
    2020-12-09 20:13

    The declaration

    using C::a
    

    brings "a" to the local naming scope so that you can later use "a" to refere to "C::a"; since that, "C::a" and "a" are interchangeable as long as you don't declare a local variable with name "a".

    The declaration does not change access rights; you can access "a" in the subclass only because "a" is not private.

提交回复
热议问题