公共嵌套类和常规类之间有什么区别吗? [英] Is there any difference between a public nested class and a regular class?
本文介绍了公共嵌套类和常规类之间有什么区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有:
class A {
public:
class B {
};
};
这个公共嵌套类和只是一个普通B类有什么区别cpp文件,除了A :: B必须在第一个选项中使用的事实。
Is there any difference between that public nested class and just a regular B class which is defined in its own cpp file, except for the fact that A::B must be used in the first option?
推荐答案
,除了 A :: B
是 A
的成员,因此具有对私人成员的所有访问权限 A
任何其他成员都会有。
There is essentially no difference, except that A::B
is a member of A
, and so has all the access rights to private members of A
that any other member would have.
这篇关于公共嵌套类和常规类之间有什么区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文