C ++的默认继承访问说明符? [英] C++'s default inheritance access specifier?
问题描述
我有一些遗留代码,我必须换行,我遇到了这个声明:
I have some legacy code that I have to wrap, and I have come across this declaration:
class Foo : Bar
{
// ...
};
这似乎是在GCC下编译的。我知道这是坏的,但我不能改变它。我的问题是,如果没有继承访问说明符,C ++编译器如何处理它?</ p>
This seems to compile under GCC. I know it's bad, but I can't change it. My question is, if no inheritance access specifier is present, how does the C++ compiler handle it?
推荐答案
称为访问修饰符。它被称为访问说明符
BTW, it is not called access modifier. It is called access specifier
$ 11.2 / 2 - 没有
基类的访问限定符,$当派生的
类用class-key
struct定义时,假定b $ b public;当
类用class-key
类定义时,假定private。
$11.2/2 - "In the absence of an access-specifier for a base class, public is assumed when the derived class is defined with the class-key struct and private is assumed when the class is defined with the class-key class."
在您的上下文中,'Bar'是'Foo'的私有基类
In your context, 'Bar' is a private base class of 'Foo'
这篇关于C ++的默认继承访问说明符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!