[英]C++: How to inherit from enclosed class
我想从其封闭的类继承一个类,如下所示:
class A : public A::B { public: class B {}; };
但是,编译器抱怨没有定义A::B :
A::B
error: expected class-name before '{' token class A : public A::B {
也就是说, A::B将无法使用,直到定义A是完整的。
A
我试图以上述开头
class A; class A::B;
但这没有帮助。 如何获得正确的声明和定义?
注意:本质上,我正在尝试与此问题相反。
这是不可能的,没有定义外部类就无法声明内部类。
在指定继承的位置,尚不知道内部类。 因此,您无法做到这一点。 但是,如果要限制范围,则只需使用名称空间,例如将其称为detail或implementation 。
detail
implementation
[英]How to inherit from Template class C++
[英]How to inherit from c++ iterator class?
[英]How to inherit abstract behavior from c++ base class
[英]How to inherit methods from a parent class in C++
[英]How to inherit from C++ class in lua using SWIG
[英]How to inherit from array built in class in c++
[英]c++ inherit from a virtal base class
[英]C++ a class inherit from a type
[英]Inherit from arbitrary class in c++?
[英]Inherit C++ class from protobuf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.